fix useStateFromStores JSDoc

Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
main
Vendicated 6 months ago
parent 75847147d1
commit 97acffafcc
No known key found for this signature in database
GPG Key ID: D66986BAF75ECF18

@ -64,23 +64,15 @@ export let DraftStore: t.DraftStore;
/** /**
* React hook that returns stateful data for one or more stores * React hook that returns stateful data for one or more stores
* You might need a custom comparator (4th argument) if your store data is an object * You might need a custom comparator (4th argument) if your store data is an object
*
* @param stores The stores to listen to * @param stores The stores to listen to
* @param mapper A function that returns the data you need * @param mapper A function that returns the data you need
* @param idk some thing, idk just pass null * @param dependencies An array of reactive values which the hook depends on. Use this if your mapper or equality function depends on the value of another hook
* @param isEqual A custom comparator for the data returned by mapper * @param isEqual A custom comparator for the data returned by mapper
* *
* @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id); * @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id);
*/ */
export const { useStateFromStores }: { // eslint-disable-next-line prefer-destructuring
useStateFromStores: <T>( export const useStateFromStores: t.useStateFromStores = findByPropsLazy("useStateFromStores").useStateFromStores;
stores: t.FluxStore[],
mapper: () => T,
idk?: any,
isEqual?: (old: T, newer: T) => boolean
) => T;
}
= findByPropsLazy("useStateFromStores");
waitForStore("DraftStore", s => DraftStore = s); waitForStore("DraftStore", s => DraftStore = s);
waitForStore("UserStore", s => UserStore = s); waitForStore("UserStore", s => UserStore = s);

@ -182,3 +182,10 @@ export class GuildStore extends FluxStore {
getRoles(guildId: string): Record<string, Role>; getRoles(guildId: string): Record<string, Role>;
getAllGuildRoles(): Record<string, Record<string, Role>>; getAllGuildRoles(): Record<string, Record<string, Role>>;
} }
export type useStateFromStores = <T>(
stores: t.FluxStore[],
mapper: () => T,
dependencies?: any,
isEqual?: (old: T, newer: T) => boolean
) => T;

Loading…
Cancel
Save