react-hooks-global-states 1.0.3 → 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/README.md CHANGED
@@ -1,16 +1,22 @@
1
- # react-hooks-global-states
1
+ # react-hooks-global-states 🌟
2
2
 
3
- This is a package to easily handling **global state hooks** across your **react components**
3
+ ![Image John Avatar](https://raw.githubusercontent.com/johnny-quesada-developer/global-hooks-example/main/public/avatar2.jpeg)
4
4
 
5
- For seen a running example of the hooks, you can check the following link: [react-global-state-hooks-example](https://johnny-quesada-developer.github.io/react-global-state-hooks-example/)
5
+ Hi There! Welcome to **react-hooks-global-states** your New State Management Solution for React Components 🚀
6
6
 
7
- To see **TODO-LIST** with the hooks and **async storage** take a look here: [todo-list-with-global-hooks](https://github.com/johnny-quesada-developer/todo-list-with-global-hooks.git).
7
+ Are you looking for a solution to manage **global state** in your **React components**? Look no further!
8
8
 
9
- To see how to create a custom hook connected to your favorite async storage, please refer to the documentation section titled **Extending Global Hooks**
9
+ **react-hooks-global-states** is your option for efficiently handling global state management in your React applications.
10
10
 
11
- You can also see an introduction video [here!](https://www.youtube.com/watch?v=1UBqXk2MH8I), you can see the code of the video here: [global-hooks-example](https://github.com/johnny-quesada-developer/global-hooks-example), and a live version of it here: [global-hooks-example-live](https://johnny-quesada-developer.github.io/global-hooks-example/)
11
+ One line of code for a **global state**! try it out now on [CODEPEN-react-global-state-hooks](https://codepen.io/johnnynabetes/pen/WNmeGwb?editors=0010) and witness the magic ✨.
12
12
 
13
- **react-hooks-global-states** is compatible with both **React** and **React Native**. However, if you prefer, you can also explore [**react-global-state-hooks**](https://www.npmjs.com/package/react-global-state-hooks) for web applications, and [**react-native-global-state-hooks**](https://www.npmjs.com/package/react-native-global-state-hooks) for React Native projects. Each of these libraries extends the capabilities of **react-hooks-global-states** to suit the specific environments.
13
+ For a deeper dive into how these hooks work, check out a comprehensive example at [react-global-state-hooks-example](https://johnny-quesada-developer.github.io/react-global-state-hooks-example/) 📘.
14
+
15
+ Want to explore how it works with **React Native**? Head over to [react-native-global-state-hooks](https://www.npmjs.com/package/react-native-global-state-hooks) for a hands-on experience 📱. You can also explore a **TODO-LIST** example using global state and asynchronous storage by heading to [todo-list-with-global-hooks](https://github.com/johnny-quesada-developer/todo-list-with-global-hooks.git) 📝.
16
+
17
+ For a more visual introduction, watch our informative video [here!](https://www.youtube.com/watch?v=1UBqXk2MH8I) 🎥 and dive into the code on [global-hooks-example](https://github.com/johnny-quesada-developer/global-hooks-example) 🧩.
18
+
19
+ The best part? **react-hooks-global-states** is compatible with both **React** and **React Native**. If you're building web applications, explore [**react-global-state-hooks**](https://www.npmjs.com/package/react-global-state-hooks), and for your React Native projects, check out [**react-native-global-state-hooks**](https://www.npmjs.com/package/react-native-global-state-hooks). These specialized libraries extend the capabilities of **react-hooks-global-states** to perfectly fit your specific development environments. Discover the ease of global state management today! 🌐
14
20
 
15
21
  # Creating a global state
16
22
 
@@ -1,4 +1,4 @@
1
- import { ActionCollectionConfig, StateSetter, GlobalStoreConfig, ActionCollectionResult, StateConfigCallbackParam, MetadataSetter, UseHookConfig, StateGetter, SubscribeCallbackConfig, SubscribeCallback, SelectorCallback, SubscriberParameters, SubscriptionCallback, MetadataGetter } from "./GlobalStore.types";
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>["onInit"];
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>["onStateChanged"];
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>["onSubscribed"];
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>["computePreventStateChange"];
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",
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.4.2",
70
- "tslib": "^2.5.0",
71
- "typescript": "^4.9.5",
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
  },