react-native-global-state-hooks 2.0.7 → 2.1.1

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.
@@ -1,66 +0,0 @@
1
- /**
2
- * @param {StateSetter<IState>} setter - add a new value to the state
3
- * @returns {void} result - void
4
- */
5
- export type StateSetter<IState> = (setter: IState | ((state: IState) => IState)) => void;
6
- /**
7
- * This is the structure required by the API actions in order to be able to capture action parameters and inject state setter into actions.
8
- */
9
- export type IActionConfig<IState> = (...params: any[]) => (setter: StateSetter<IState>, currentState: IState) => unknown;
10
- /**
11
- * Configuration of you API
12
- */
13
- export interface IActionCollectionConfig<IState> {
14
- [key: string]: IActionConfig<IState>;
15
- }
16
- /**
17
- * This is the API result of the hook (if you passed an API as a parameter)
18
- */
19
- export type IActionCollectionResult<IState, IActions extends IActionCollectionConfig<IState> | null> = {
20
- [key in keyof IActions]: (...params: any[]) => unknown;
21
- };
22
- /**
23
- * Hook result, if you passed an API as a parameter it will be returned in the second position of the hook invoke.
24
- */
25
- export type IHookResult<IState, IActions extends IActionCollectionConfig<IState> | null = null, IApi extends IActionCollectionResult<IState, IActions> | null = IActions extends null ? null : IActionCollectionResult<IState, IActions>> = IApi extends null ? StateSetter<IState> : IActions extends IActionCollectionConfig<IState> ? IApi extends IActionCollectionResult<IState, IActions> ? IApi : StateSetter<IState> : StateSetter<IState>;
26
- /**
27
- * This is a class to create global-store objects
28
- * @template IState
29
- * @param {IState} state - Initial state,
30
- * @template IPersist
31
- * @param {IPersist} persistStoreAs - A name that indicates if the store should be persisted at the asyncStorage
32
- * @template IsPersist
33
- * @param {IsPersist} isPersist - Calculated flag that indicates if the store is persisted
34
- * @template IActions
35
- * @param {IActions} actions - An specific api to restrict the use of the state,
36
- * this will disable the default return of the state-setter of the hook, and instead will return the API
37
- * @param {string} persistStoreAs - A name if you want to persist the state of the store in localstorage
38
- * */
39
- export interface IGlobalState<IState, IPersist extends string | null = null, IActions extends IActionCollectionConfig<IState> | null = null> {
40
- persistStoreAs: IPersist;
41
- isPersistStore: boolean;
42
- /**
43
- * This function can be used to format the data after it is loaded from the asyncStorage
44
- */
45
- onPersistStorageLoad: (obj: unknown) => (IState | null);
46
- /**
47
- * Returns a global hook that will share information across components by subscribing them to a specific store.
48
- * @return [currentState, GlobalState.IHookResult<IState, IActions, IApi>, initialStatePersistStorage | null, isUpdatedPersistStorage | null]
49
- */
50
- getHook: <IApi extends IActions extends IActionCollectionResult<IState, IActions> ? IActionCollectionResult<IState, IActions> : null>() => () => [
51
- IState,
52
- IHookResult<IState, IActions, IApi>,
53
- IPersist extends null ? false : true extends true ? boolean : null
54
- ];
55
- /**
56
- * This is an access to the subscribers queue and to the current state of a specific store...
57
- * THIS IS NOT A REACT-HOOK, so you could use it everywhere example other hooks, and services.
58
- * @return [currentState, GlobalState.IHookResult<IState, IActions, IApi>]
59
- */
60
- getHookDecoupled: <IApi extends IActions extends IActionCollectionResult<IState, IActions> ? IActionCollectionResult<IState, IActions> : null>() => [
61
- () => IPersist extends string ? Promise<IState> : IState,
62
- IHookResult<IState, IActions, IApi>
63
- ];
64
- deleteAsyncStoreItem: () => Promise<void>;
65
- }
66
- //# sourceMappingURL=GlobalStoreTypes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GlobalStoreTypes.d.ts","sourceRoot":"","sources":["../src/GlobalStoreTypes.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,MAAM,MAAM,WAAW,CAAC,MAAM,IAAI,CAChC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,KACzC,IAAI,CAAC;AAEV;;EAEE;AACF,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,CAElC,GAAG,MAAM,EAAE,GAAG,EAAE,KACb,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC;AAEpE;;EAEE;AACF,MAAM,WAAW,u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