Your store's state interface
Create your Store with an initial state.
The initial state for this store
See Immer's documentation on Patches. Will apply any patches as an update to this store's state.
See also: Store.listenToPatches
The patches to apply.
React to changes on this store by watching a sub-selection of its state and then updating the store directly (similar to subscribe, but allows direct batched updates to the store on changes)
The type of the returned watched value
The selector function. Return the values you want to watch for changes on.
The reaction. The function which will run with those changes whenever they have changed.
An un-subscribe function. Stops listening for watched changes.
Returns the raw state object contained within this store at this moment
WARNING
Most of the time, if you're using this in your App, there's probably a better way to do it
Listen to all changes made to this store's state in the form of "patches" sent to a patch listener. This is basically a direct link to Immer's functionality of patches.
See also: Store.applyPatches
A function which matches exactly the patch callback functionality in Immer
Replace the store's state entirely with a new state value
Subscribe to changes on this store by watching a sub-selection of its state
The type of the returned watched value
The selector function. Return the values you want to watch for changes on.
The listener. The function which will run with those changes whenever they have changed.
The new watched value (returned from the selection function)
Your entire store's state (read-only, do not mutate)
The previous value that was watched
An un-subscribe function. Stops listening for watched changes.
The store's update function. Pass in a function which takes the current store's state and mutates it directly, thanks to Immer
The update function. Takes the current state and mutates it to the next state.
Exactly the same as the Immer patches callback. Gives you the patches which represent the exact granular changes that happened to your store's state during this update.
🎣 React hook
Makes a local component-bound copy ot this store, using the initial state that was set when this store was created, which otherwise functions exactly the same.
Dependencies, which if changed will cause a new local Store to be created and returned - again set to the initial state.
🎣 React hook
Makes a local component-bound copy of this store, using the current snapshot of its state, which otherwise functions exactly the same.
Dependencies, which if changed will cause a new local Store to be created and returned - again at the Store's current snapshot at that time
🎣 React hook
Select and use the store's state in your React components
Generated using TypeDoc
The Store. A home for your state, and from whence you can pull it, shape it and listen to it in various ways.