Thanks for your input! Do you mind giving 2-3 examples of good uses of multiple reducers for the same action?
Thanks for your input! Do you mind giving 2-3 examples of good uses of multiple reducers for the same action?
Another example is url updates, I use state-driven-routing and when a url update happens many reducers need to respond to get the pieces of state they are concerned about.
Another example is a login status change, many reducers may need to update themselves if a user logs in our logs out.
It's the difference between having tons of highly specific 1:1 actions getting called from the action creator with their relationship to the root action obfuscated vs. having 1 action that many respond to with their relationship to that action clearly denoted.
To take it a bit further, it reminds me of refactoring vs adding another "if" statement - the former requires comprehensive understanding of the holistic purpose of the system with the dependent relationships properly defined (anti-fragile), whereas the latter is a temporary bandaid that can be implemented with less thought (and the sideeffects that come with it).
Wouldn't the components handle this change and dispatch any actions needed?
> a login status change, many reducers may need to update themselves if a user logs in our logs out.
Again, couldn't this be handled at the component level? It seems risky to have multiple sources of truth for data.
There wouldn't be more than a single source of a given truth, the multiple responders pull different truths relevant to them, the combination of which making the complete app state.