react-hooks-global-states 1.0.4 → 1.0.5
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, StateConfigCallbackParam, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, MetadataGetter } from
|
|
1
|
+
import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, StateConfigCallbackParam, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, 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
|
|
@@ -40,7 +40,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateSetter extends
|
|
|
40
40
|
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
41
41
|
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
42
42
|
* */
|
|
43
|
-
protected onInit?: GlobalStoreConfig<TState, TMetadata, TStateSetter>[
|
|
43
|
+
protected onInit?: GlobalStoreConfig<TState, TMetadata, TStateSetter>['onInit'];
|
|
44
44
|
/**
|
|
45
45
|
* execute every time the state is changed
|
|
46
46
|
* @template {TState} TState - The type of the state object
|
|
@@ -52,7 +52,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateSetter extends
|
|
|
52
52
|
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
53
53
|
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
54
54
|
* */
|
|
55
|
-
protected onStateChanged?: GlobalStoreConfig<TState, TMetadata, TStateSetter>[
|
|
55
|
+
protected onStateChanged?: GlobalStoreConfig<TState, TMetadata, TStateSetter>['onStateChanged'];
|
|
56
56
|
/**
|
|
57
57
|
* Execute each time a new component gets subscribed to the store
|
|
58
58
|
* @template {TState} TState - The type of the state object
|
|
@@ -64,7 +64,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateSetter extends
|
|
|
64
64
|
* @param {Dispatch<SetStateAction<TMetadata>>} parameters.setMetadata - The setMetadata function to update the metadata
|
|
65
65
|
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
66
66
|
* */
|
|
67
|
-
protected onSubscribed?: GlobalStoreConfig<TState, TMetadata, TStateSetter>[
|
|
67
|
+
protected onSubscribed?: GlobalStoreConfig<TState, TMetadata, TStateSetter>['onSubscribed'];
|
|
68
68
|
/**
|
|
69
69
|
* Execute every time a state change is triggered and before the state is updated, it allows to prevent the state change by returning true
|
|
70
70
|
* @template {TState} TState - The type of the state object
|
|
@@ -77,7 +77,7 @@ export declare class GlobalStore<TState, TMetadata = null, TStateSetter extends
|
|
|
77
77
|
* @param {() => TMetadata} parameters.getMetadata - The getMetadata function to get the metadata
|
|
78
78
|
* @returns {boolean} - true to prevent the state change, false to allow the state change
|
|
79
79
|
* */
|
|
80
|
-
protected computePreventStateChange?: GlobalStoreConfig<TState, TMetadata, TStateSetter>[
|
|
80
|
+
protected computePreventStateChange?: GlobalStoreConfig<TState, TMetadata, TStateSetter>['computePreventStateChange'];
|
|
81
81
|
/**
|
|
82
82
|
* We use a wrapper in order to be able to force the state update when necessary even with primitive types
|
|
83
83
|
*/
|
|
@@ -148,7 +148,7 @@ export type ActionCollectionResult<TState, TMetadata, TStateSetter extends Actio
|
|
|
148
148
|
* @template {TStateSetter} TStateSetter - The storeActionsConfig type (optional) - if you pass an storeActionsConfig the hook will return an object with the actions
|
|
149
149
|
* @template {ActionCollectionResult<TState, TStateSetter>} TStateSetter - the result of the API (optional) - if you don't pass an API as a parameter, you can pass null
|
|
150
150
|
* */
|
|
151
|
-
export type StateConfigCallbackParam<TState, TMetadata, TStateSetter extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = {
|
|
151
|
+
export type StateConfigCallbackParam<TState = any, TMetadata = null, TStateSetter extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = {
|
|
152
152
|
actions: ActionCollectionResult<TState, TMetadata, TStateSetter>;
|
|
153
153
|
} & StoreTools<TState, TMetadata>;
|
|
154
154
|
/**
|
|
@@ -157,7 +157,7 @@ export type StateConfigCallbackParam<TState, TMetadata, TStateSetter extends Act
|
|
|
157
157
|
* @template {TMetadata} TMetadata - The metadata type
|
|
158
158
|
* @template {TStateSetter} TStateSetter - The storeActionsConfig type (optional) - if you pass an storeActionsConfig the hook will return an object with the actions
|
|
159
159
|
*/
|
|
160
|
-
export type StateChangesParam<TState, TMetadata, TStateSetter extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = StateConfigCallbackParam<TState, TMetadata, TStateSetter> & StateChanges<TState>;
|
|
160
|
+
export type StateChangesParam<TState = any, TMetadata = null, TStateSetter extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>> = StateConfigCallbackParam<TState, TMetadata, TStateSetter> & StateChanges<TState>;
|
|
161
161
|
/**
|
|
162
162
|
* Configuration of the store (optional) - if you don't need to use the store configuration you don't need to pass this parameter
|
|
163
163
|
* @param {StateConfigCallbackParam<TState, TMetadata> => void} onInit - callback function called when the store is initialized
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-hooks-global-states",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "This is a package to easily handling global-state across your react-components No-redux",
|
|
5
5
|
"main": "lib/bundle.js",
|
|
6
6
|
"types": "lib/src/index.d.ts",
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"react": ">=17.0.0",
|
|
67
67
|
"react-test-renderer": "^17.0.1",
|
|
68
68
|
"ts-jest": "^26.4.4",
|
|
69
|
-
"ts-loader": "^9.
|
|
70
|
-
"tslib": "^2.
|
|
71
|
-
"typescript": "^
|
|
69
|
+
"ts-loader": "^9.5.1",
|
|
70
|
+
"tslib": "^2.6.2",
|
|
71
|
+
"typescript": "^5.3.3",
|
|
72
72
|
"webpack": "^5.76.3",
|
|
73
73
|
"webpack-cli": "^5.0.1"
|
|
74
74
|
},
|