|
|
@ -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);
|
|
|
|