You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> - __getStore__: function that returns the store object.
89
-
> - __updateStore__: function that updates the store: it receives a callback with an only parameter, the store, and return void. Inside this function it can possible to modify to any store properties: changes will be notified to every user of the store.
90
-
> - __usePubSubStore__: It's the hook to be used inside components to access the store. It receives an optional callback _subscribe_ to specify to which part of store you want access and to be notified of its changes. If no callback is gived, it returns the whole store. It returns an array of three elements:
91
-
> - _first element_: the __state__. Represents the slice of store indicated by _subscribe_ callback or the whole store.
92
-
> - _second element_: the __updateState__. An _immutable_ function that represents the function to update the state. Depending on whether the hook was invoked by passing the _subscribe_ callback or not, it receives a new value for the slice or the entire store or a callback with only one parameter, the current slice or store, which returns a new slice or value of the shop.
93
-
> - _third element_: the __getState__. An _immutable_ function that returns the current state returned by hook that can be a slice or the whole store, depending on the present of the _subscribe_ callback.
89
+
> - __updateStore__: function that updates the store: it receives a callback with an only parameter, the store, and return void. Inside this function it can be possible to modify any store properties: changes will be published to every subscriber.
90
+
> - __usePubSubStore__: It's the hook to be used inside components to access the store. It receives an optional callback _subscribe_ to specify to which part of store you want to subscribe.If callback missed, the whole store will be subscribed. It returns an array of three elements:
91
+
> - _first element_: the __state__. It represents what has been subscribed.
92
+
> - _second element_: the __updateState__. An _immutable_ function that represents the function to update the state. It can be executed given it a new version of the subscribed value or with a callback that receives the subscribed value and returns a new version of it.
93
+
> - _third element_: the __getState__. An _immutable_ function that returns the current subscribed value.
* **`createPubSubStore`**: A state management hook implemented on Publish-Subscribe pattern. It allows components to subscribe to state changes and receive updates whenever the state is modified, providing a scalable and decoupled state management solution.
21
41
* @param {T extends Record<string, unknown>} obj - Object that rapresent the initialState of the store.
22
42
* @param {boolean} [persist=false] - boolean that indicates if the store value will be persisted on the local Storage.
* - __getStore__: function that returns the store object.
26
-
* - __updateStore__: function that updates the store: it receives a callback with an only parameter, the store, and return void. Inside this function it can be possible to modify any store properties: changes will be published to every subscribers.
46
+
* - __updateStore__: function that updates the store: it receives a callback with an only parameter, the store, and return void. Inside this function it can be possible to modify any store properties: changes will be published to every subscriber.
27
47
* - __usePubSubStore__: It's the hook to be used inside components to access the store. It receives an optional callback _subscribe_ to specify to which part of store you want to subscribe.If callback missed, the whole store will be subscribed. It returns an array of three elements:
28
48
* - _first element_: the __state__. It represents what has been subscribed.
29
49
* - _second element_: the __updateState__. An _immutable_ function that represents the function to update the state. It can be executed given it a new version of the subscribed value or with a callback that receives the subscribed value and returns a new version of it.
0 commit comments