react-hooks-global-states 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/src/GlobalStore.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateMutator extends
|
|
|
181
181
|
* Returns a custom hook that allows to handle a global state
|
|
182
182
|
* @returns {[TState, TStateMutator, TMetadata]} - The state, the state setter or the actions map, the metadata
|
|
183
183
|
* */
|
|
184
|
-
getHook: () => <State = TState>(selector?: SelectorCallback<TState, State>, config?: UseHookConfig<State>) => [state: State extends null ? TState : State, setter: keyof TStateMutator extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TStateMutator>, metadata: TMetadata];
|
|
184
|
+
getHook: () => <State = TState>(selector?: SelectorCallback<TState, State>, config?: UseHookConfig<State, TState>) => [state: State extends null ? TState : State, setter: keyof TStateMutator extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TStateMutator>, metadata: TMetadata];
|
|
185
185
|
/**
|
|
186
186
|
* Returns an array with the a function to get the state, the state setter or the actions map, and a function to get the metadata
|
|
187
187
|
* @returns {[() => TState, TStateMutator, () => TMetadata]} - The state getter, the state setter or the actions map, the metadata getter
|
|
@@ -26,7 +26,7 @@ setter: TState | ((state: TState) => TState),
|
|
|
26
26
|
* The hook to use the global state
|
|
27
27
|
* @returns {[State, StateSetter<TState>, TMetadata]} result - the state, the setter and the metadata
|
|
28
28
|
*/
|
|
29
|
-
export type StateHook<TState, TSetter, TMetadata> = <State = TState>(selector?: (state: TState) => State, config?: UseHookConfig<State>) => [state: State, stateMutator: TSetter, metadata: TMetadata];
|
|
29
|
+
export type StateHook<TState, TSetter, TMetadata> = <State = TState>(selector?: (state: TState) => State, config?: UseHookConfig<State, TState>) => [state: State, stateMutator: TSetter, metadata: TMetadata];
|
|
30
30
|
/**
|
|
31
31
|
* @description
|
|
32
32
|
* Type that prevent ts issues with merging never with other types
|
|
@@ -194,13 +194,13 @@ export type GlobalStoreConfig<TState, TMetadata, TStateMutator extends ActionCol
|
|
|
194
194
|
*/
|
|
195
195
|
computePreventStateChange?: (parameters: StateChangesParam<TState, TMetadata, TStateMutator>) => boolean;
|
|
196
196
|
} | null;
|
|
197
|
-
export type UseHookConfig<TState> = {
|
|
197
|
+
export type UseHookConfig<TState, TRoot = any> = {
|
|
198
198
|
/**
|
|
199
199
|
* The callback to execute when the state is changed to check if the same really changed
|
|
200
200
|
* If the function is not provided the derived state will perform a shallow comparison
|
|
201
201
|
*/
|
|
202
202
|
isEqual?: (current: TState, next: TState) => boolean;
|
|
203
|
-
isEqualRoot?: (current:
|
|
203
|
+
isEqualRoot?: (current: TRoot, next: TRoot) => boolean;
|
|
204
204
|
dependencies?: unknown[];
|
|
205
205
|
};
|
|
206
206
|
/**
|
package/package.json
CHANGED