Using createListenerMiddleware per slice #3665
Replies: 3 comments 1 reply
-
No, don't do that! You should have one instance of the listener middleware in the app's store. Having multiple copies is both redundant, and adding a lot of extra overhead for every dispatched action. Just add the one listener middleware instance, then add as many listener entries as you need throughout the app: (Just out of curiosity, what sort of "per-slice"-type behavior are you wanting to add?) |
Beta Was this translation helpful? Give feedback.
-
Thank you, that was actually my specific concern. It's probable that we are abusing slices... We are creating a separate slice for each defined feature area of the app. A handful of the slices will have 10+ (but < 30) reducers/actions, while all the others are definitely <10 reducers / actions. Again, its mainly to narrow the focus of each "feature" than anything else. |
Beta Was this translation helpful? Give feedback.
-
And I should have finished reading the docs... Thanks for the link Curious to hear if you think I'm being ridiculous with my slice configuration, otherwise I'll mark this as closed |
Beta Was this translation helpful? Give feedback.
-
We have multiple slices (> 10 but < 20) and we would love to use
createListenerMiddleware
within each slice.I'm assuming it is safe to call
createListenerMiddleware()
in each slice and then have the store do something like:Again, I'm assuming this is safe, but thought I would check just to be sure.
Beta Was this translation helpful? Give feedback.
All reactions