|
|
|
@ -64,23 +64,15 @@ export let DraftStore: t.DraftStore;
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*
|
|
|
|
|
* @param stores The stores to listen to
|
|
|
|
|
* @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
|
|
|
|
|
*
|
|
|
|
|
* @example const user = useStateFromStores([UserStore], () => UserStore.getCurrentUser(), null, (old, current) => old.id === current.id);
|
|
|
|
|
*/
|
|
|
|
|
export const { useStateFromStores }: {
|
|
|
|
|
useStateFromStores: <T>(
|
|
|
|
|
stores: t.FluxStore[],
|
|
|
|
|
mapper: () => T,
|
|
|
|
|
idk?: any,
|
|
|
|
|
isEqual?: (old: T, newer: T) => boolean
|
|
|
|
|
) => T;
|
|
|
|
|
}
|
|
|
|
|
= findByPropsLazy("useStateFromStores");
|
|
|
|
|
// eslint-disable-next-line prefer-destructuring
|
|
|
|
|
export const useStateFromStores: t.useStateFromStores = findByPropsLazy("useStateFromStores").useStateFromStores;
|
|
|
|
|
|
|
|
|
|
waitForStore("DraftStore", s => DraftStore = s);
|
|
|
|
|
waitForStore("UserStore", s => UserStore = s);
|
|
|
|
|