react-native-global-state-hooks 5.0.4 → 5.0.6
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/{GlobalStore.d.ts → src/GlobalStore.d.ts} +2 -2
- package/lib/{GlobalStore.functionHooks.d.ts → src/GlobalStore.functionHooks.d.ts} +3 -11
- package/lib/{GlobalStore.types.d.ts → src/GlobalStore.types.d.ts} +8 -0
- package/package.json +2 -2
- /package/lib/{GlobalStore.combiners.d.ts → src/GlobalStore.combiners.d.ts} +0 -0
- /package/lib/{GlobalStore.utils.d.ts → src/GlobalStore.utils.d.ts} +0 -0
- /package/lib/{GlobalStoreAbstract.d.ts → src/GlobalStoreAbstract.d.ts} +0 -0
- /package/lib/{index.d.ts → src/index.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, StateConfigCallbackParam, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SetStateCallback, SubscriberParameters, SubscriptionCallback } from "./GlobalStore.types";
|
|
1
|
+
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, StateConfigCallbackParam, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SetStateCallback, SubscriberParameters, SubscriptionCallback, MetadataGetter } from "./GlobalStore.types";
|
|
2
2
|
export declare const throwNoSubscribersWereAdded: () => never;
|
|
3
3
|
/**
|
|
4
4
|
* The GlobalStore class is the main class of the library and it is used to create a GlobalStore instances
|
|
@@ -177,7 +177,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateSetter extends
|
|
|
177
177
|
* 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
|
|
178
178
|
* @returns {[() => TState, TStateSetter, () => TMetadata]} - The state getter, the state setter or the actions map, the metadata getter
|
|
179
179
|
* */
|
|
180
|
-
getHookDecoupled: () => [
|
|
180
|
+
getHookDecoupled: () => [StateGetter<TState>, keyof TStateSetter extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TStateSetter>, MetadataGetter<TMetadata>];
|
|
181
181
|
/**
|
|
182
182
|
* returns a wrapper for the setState function that will update the state and all the subscribers
|
|
183
183
|
* @param {{ invokerSetState?: SetStateCallback }} parameters - The setState function of the component that invoked the state change (optional) (default: null) this is used to updated first the component that invoked the state change
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { ActionCollectionConfig, StateSetter, ActionCollectionResult, UseHookConfig, AvoidNever, UnsubscribeCallback, StateHook, StateGetter, createStateConfig, CustomGlobalHookBuilderParams, CustomGlobalHookParams, SelectorCallback, SubscribeToEmitter } from "./GlobalStore.types";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a global
|
|
4
|
-
* @param {TState} state - The initial state
|
|
5
|
-
* @param {{ config?: GlobalStoreConfig<TState, TMetadata, TStateSetter>; actionsConfig?: TStateSetter | null }} parameters - The configuration object (optional) (default: null)
|
|
6
|
-
* @param {GlobalStoreConfig<TState, TMetadata, TStateSetter>} parameters.config - The configuration object
|
|
7
|
-
* @param {TStateSetter | null} parameters.actionsConfig - The setter configuration object (optional) (default: null)
|
|
3
|
+
* Creates a global state with the given state and config.
|
|
8
4
|
* @returns {} [HOOK, DECOUPLED_GETTER, DECOUPLED_SETTER] this is an array with the hook, the decoupled getState function and the decoupled setter of the state
|
|
9
5
|
*/
|
|
10
|
-
export declare const createGlobalStateWithDecoupledFuncs: <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, TMetadata> = null>(state: TState, { actions, ...config }?: createStateConfig<TState, TMetadata, TActions>) => [
|
|
6
|
+
export declare const createGlobalStateWithDecoupledFuncs: <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, TMetadata> = null>(state: TState, { actions, ...config }?: createStateConfig<TState, TMetadata, TActions>) => [StateHook<TState, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TActions>, TMetadata>, StateGetter<TState>, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TActions>];
|
|
11
7
|
/**
|
|
12
8
|
* Creates a global hook that can be used to access the state and actions across the application
|
|
13
|
-
* @param {TState} state - The initial state of the store
|
|
14
|
-
* @param {{ config?: GlobalStoreConfig<TState, TMetadata, TStateSetter>; actionsConfig?: TStateSetter | null }} parameters - The configuration object of the store and the configuration object of the state setter (optional) (default: null)
|
|
15
|
-
* @param {GlobalStoreConfig<TState, TMetadata, TStateSetter>} parameters.config - The configuration object of the store
|
|
16
|
-
* @param {TStateSetter | null} parameters.actionsConfig - The configuration object of the state setter (optional) (default: null)
|
|
17
9
|
* @returns {} - () => [TState, Setter, TMetadata] the hook that can be used to access the state and the setter of the state
|
|
18
10
|
*/
|
|
19
11
|
export declare const createGlobalState: <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, TMetadata> = null>(state: TState, config?: createStateConfig<TState, TMetadata, TActions>) => StateHook<TState, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, TMetadata, TActions>, TMetadata>;
|
|
@@ -22,7 +14,7 @@ export declare const createGlobalState: <TState, TMetadata = null, TActions exte
|
|
|
22
14
|
* Use this function to create a custom global store.
|
|
23
15
|
* You can use this function to create a store with async storage.
|
|
24
16
|
*/
|
|
25
|
-
export declare const createCustomGlobalStateWithDecoupledFuncs: <TInheritMetadata = null, TCustomConfig = null>({ onInitialize, onChange, }: CustomGlobalHookBuilderParams<TInheritMetadata, TCustomConfig>) => <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>> = null>(state: TState, { config: customConfig, onInit, onStateChanged, ...parameters }?: CustomGlobalHookParams<TCustomConfig, TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>, TActions>) => [
|
|
17
|
+
export declare const createCustomGlobalStateWithDecoupledFuncs: <TInheritMetadata = null, TCustomConfig = null>({ onInitialize, onChange, }: CustomGlobalHookBuilderParams<TInheritMetadata, TCustomConfig>) => <TState, TMetadata = null, TActions extends ActionCollectionConfig<TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>> = null>(state: TState, { config: customConfig, onInit, onStateChanged, ...parameters }?: CustomGlobalHookParams<TCustomConfig, TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>, TActions>) => [StateHook<TState, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>, TActions>, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>>, StateGetter<TState>, keyof TActions extends never ? StateSetter<TState> : ActionCollectionResult<TState, AvoidNever<TInheritMetadata> & AvoidNever<TMetadata>, TActions>];
|
|
26
18
|
/**
|
|
27
19
|
* @description
|
|
28
20
|
* Use this function to create a custom global hook which contains a fragment of the state of another hook or a fragment
|
|
@@ -236,10 +236,14 @@ export type StateGetter<TState> = <Subscription extends Subscribe | false = fals
|
|
|
236
236
|
* use the methods subscribe and subscribeSelect to subscribe to the store changes
|
|
237
237
|
*/
|
|
238
238
|
callback?: Subscription extends Subscribe ? SubscriberCallback<TState> : null) => Subscription extends Subscribe ? UnsubscribeCallback : TState;
|
|
239
|
+
export type MetadataGetter<TMetadata> = () => TMetadata;
|
|
239
240
|
/**
|
|
240
241
|
* Constant value type to indicate that the getter is a subscription
|
|
241
242
|
*/
|
|
242
243
|
export type Subscribe = true;
|
|
244
|
+
/**
|
|
245
|
+
* Configuration of the state (optional) - if you don't need to use the state configuration you don't need to pass this parameter
|
|
246
|
+
*/
|
|
243
247
|
export type createStateConfig<TState, TMetadata, TActions extends ActionCollectionConfig<TState, TMetadata> | null = null> = {
|
|
244
248
|
/**
|
|
245
249
|
* @description
|
|
@@ -259,6 +263,10 @@ export type CustomGlobalHookBuilderParams<TInheritMetadata = null, TCustomConfig
|
|
|
259
263
|
*/
|
|
260
264
|
onChange: ({ setState, setMetadata, getMetadata, getState, actions, }: StateChangesParam<any, TInheritMetadata>, config: TCustomConfig) => void;
|
|
261
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* @description
|
|
268
|
+
* Configuration of the custom global hook
|
|
269
|
+
*/
|
|
262
270
|
export type CustomGlobalHookParams<TCustomConfig, TState, TMetadata, TActions extends ActionCollectionConfig<TState, TMetadata> | null> = {
|
|
263
271
|
/**
|
|
264
272
|
* @description
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-global-state-hooks",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.6",
|
|
4
4
|
"description": "This is a package to easily handling global-state across your react-native-components No-redux",
|
|
5
5
|
"main": "lib/bundle.js",
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
6
|
+
"types": "lib/src/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib"
|
|
9
9
|
],
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|