UNPKG

react-select-table

Version:
101 lines (100 loc) 3.26 kB
/** * @namespace HooksTypes */ /** * @typedef {Hooks} HooksTypes.HooksClass */ /** * @typedef {import('./Actions').ActionsTypes.ActionsClass} ActionsClass */ /** * @typedef {import('../store/store').StoreTypes.State} StateType */ /** * Returns the table's slice of the state * * @callback HooksTypes.getState * @returns {StateType} The table state */ /** * Returns a property from the table state * * @template Selected * @callback HooksTypes.selector * @param {StateType} state The table state * @returns {Selected} A property from the state */ /** * Should return true if a render is deemed necessary because of a state property change * * @template Selected * @callback HooksTypes.equalityFn * @param {Selected} a The previous value * @param {Selected} b The current value * @returns {boolean} Whether the values are considered equal */ export default class Hooks { constructor(options: any, selectors: any, actions: any); /** @private */ private actions; /** @private */ private selectors; /** * The normal useSelector hook, bound to {@link Options.context} * * @type {import('react-redux').useSelector} */ useRootSelector: any; /** * The normal useDispatch hook, bound to {@link Options.context} * * @type {import('react-redux').useDispatch} */ useDispatch: any; /** * The normal useStore hook, bound to {@link Options.context} * * @type {import('react-redux').useStore} */ useStore: any; /** * Like normal useSelector, but the table's slice of the state is passed to the selector, instead of the root state * * @template Selected * @param {HooksTypes.selector<Selected>} selector The selector * @param {HooksTypes.equalityFn<Selected>} [equalityFn] The equality comparator * @returns {Selected} The value returned from the selector */ useSelector<Selected>(selector: HooksTypes.selector<Selected>, equalityFn?: HooksTypes.equalityFn<Selected> | undefined): Selected; /** * Returns a getter for the table's slice of the state * * @returns {HooksTypes.getState} The getter for the table state */ useGetState(): HooksTypes.getState; /** * Returns the actions wrapped into dispatch calls using * {@link https://redux.js.org/api/bindactioncreators|bindActionCreators} * * @param {?object} metadata An object to be assigned to every action * @returns {ActionsClass} The actions, but calling an action dispatches it automatically */ useActions(metadata?: object | null): ActionsClass; } export namespace HooksTypes { export type HooksClass = Hooks; /** * Returns the table's slice of the state */ export type getState = () => StateType; /** * Returns a property from the table state */ export type selector<Selected> = (state: StateType) => Selected; /** * Should return true if a render is deemed necessary because of a state property change */ export type equalityFn<Selected> = (a: Selected, b: Selected) => boolean; type StateType = import('../store/store').StoreTypes.State; } export type ActionsClass = import('./Actions').ActionsTypes.ActionsClass;