useStateFromStores: Document 3rd param and fix JSDoc

This commit is contained in:
Nuckyz 2024-05-07 06:13:38 -03:00
parent 75847147d1
commit f04bd8a7ad
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -16,10 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import { proxyLazy } from "@utils/lazy";
import type * as Stores from "discord-types/stores"; import type * as Stores from "discord-types/stores";
// eslint-disable-next-line path-alias/no-relative // eslint-disable-next-line path-alias/no-relative
import { findByPropsLazy } from "../webpack"; import { findByProps, findByPropsLazy } from "../webpack";
import { waitForStore } from "./internal"; import { waitForStore } from "./internal";
import * as t from "./types/stores"; import * as t from "./types/stores";
@ -67,20 +68,17 @@ export let DraftStore: t.DraftStore;
* *
* @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 }: { export const useStateFromStores = proxyLazy(() => findByProps("useStateFromStores").useStateFromStores) as <T>(
useStateFromStores: <T>( stores: t.FluxStore[],
stores: t.FluxStore[], mapper: () => T,
mapper: () => T, dependencies?: any,
idk?: any, isEqual?: (old: T, newer: T) => boolean
isEqual?: (old: T, newer: T) => boolean ) => T;
) => T;
}
= findByPropsLazy("useStateFromStores");
waitForStore("DraftStore", s => DraftStore = s); waitForStore("DraftStore", s => DraftStore = s);
waitForStore("UserStore", s => UserStore = s); waitForStore("UserStore", s => UserStore = s);