Reputation: 757
I have some common components that dispatch an action. For example Status Selection, this component is used across my application in different modules, in each module I have effects being triggered by this action.
Now, if I have child modules: Module A -> Module B -> Module C, each listening to my Status Selection, if I'm in Module C, the actions of Module A are still being dispatched and I don't want that, I want each Module to be isolated even from its parents.
Is there a way to stop or destroy the listeners for actions after I'm not anymore in its Module?
Upvotes: 0
Views: 1190
Reputation: 15505
An action will always be dispatched to every registered reducer and effect. There is no built-in way to only dispatch an action to a specific reducer/module/effect.
Upvotes: 1
Reputation: 896
Yes you can. When you select any part of your store and u use the subscribe
method this return asubscription
you can use the method unsubscribe
when you want.
But your store not need be designed by your components. if you have a One "Status Selection" you can have StatusSelectionAState, StatusSelectionBState, StatusSelectionCState, etc ... and subscribe - unsubscribe when you want.
Upvotes: 1