UNPKG

@rbxts/rodux-hooks

Version:

Port of littensy's roact-rodux-hooked for kampf's RoactHooks library.

29 lines (28 loc) 1.34 kB
import { CoreHooks } from "@rbxts/roact-hooks"; /** * This interface allows you to easily create a hook that is properly typed for your store's root state. * * @example * interface RootState { * property: string; * } * * const useAppSelector: ITypedUseSelectorHook<RootState> = useSelector; */ export interface ITypedUseSelectorHook<State> { <Selected>(selector: (state: State) => Selected, equalityFn?: (selectedState?: Selected, oldSelectedState?: Selected) => boolean): Selected; } /** * A hook to access the Rodux Store's state. This hook takes a selector function as an argument. The selector is called * with the store state. * * This hook takes an optional equality comparison function as the second parameter that allows you to customize the * way the selected state is compared to determine whether the component needs to be re-rendered. * * @param selector - The selector function * @param equalityFn - The function that will be used to determine equality * * @returns The selected portion of the state */ export declare const useSelector: <State = {}, Selected = unknown>(hooks: CoreHooks, selector: (state: State) => Selected, equalityFn?: (selectedState?: Selected | undefined, oldSelectedState?: Selected | undefined) => boolean) => Selected; export default useSelector;