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
withRedux integrates the Redux pattern into a signalStore. Actions are currently methods of the store instance which means we don't have a global dispatching mechanism.
It is not possible for bookingStore to have a reducer on FlightStore::search. It would be possible though to dispatch search via an effect or withMethods:
In contrast to the global store, Signal Stores can be provided multiple times. That means we have more than one instance.
There are use cases, where a "local Signal Store" only needs to consume actions dispatched by its instance. The on method will get an optional option to
I prefer this approach and have a question: if a store has multiple instances, it means you need to add the dispatcher to the instance provider, right? How would you do that?
Update 1 (21.12 (17.01)): Self-dispatching external actions
Use Case
withRedux
integrates the Redux pattern into a signalStore. Actions are currently methods of the store instance which means we don't have a global dispatching mechanism.Example:
It is not possible for
bookingStore
to have a reducer onFlightStore::search
. It would be possible though to dispatchsearch
via aneffect
orwithMethods
:That works as long as we have only global stores. As soon as a global store, wants to listen to actions from al local one, the DI will fail.
Proposed Approach:
Here's a design which would introduce global actions for global and local SignalStores.
We require two new features:
To reference actions without a store's instance, we need to be able to externalize them. That is exactly what we have with the Global Store:
If another Signal Store wants to react to that action, it can do:
It will still be possible to define actions inside
withRedux::actions
.External actions are self-dispatching. They do not require a "DispatcherService", like the
Store
in the Global Store:In contrast to the global store, Signal Stores can be provided multiple times. That means we have more than one instance.
There are use cases, where a "local Signal Store" only needs to consume actions dispatched by its instance. The
on
method will get an optional option toActions have to be unique per Store class.
Abandoned (simpler) Approach: storeBound actions & inject in reducer
The text was updated successfully, but these errors were encountered: