Answer the question
In order to leave comments, you need to log in
How to build communication between reducers, and is it worth it?
Goodnight.
There is a state slice (one reducer), which stores a list of entities from the API, the isLoading flag and at the same time search data: a filter and results. I would like to break this into several slices, so that one is strictly data, the other is strictly filter, the third is strictly search, but when I started doing this, I ran into difficulties.
By concept, the reducer should only manage its own state slice. So essentially I can call one reducer from another, but that's weird, and the redux-toolkit itself is built to be unnatural.
How to be? Make a higher-order reducer that includes the union of the above reducers? Or is it better to leave one big reducer after all?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
I can call one reducer from another
action
and analyzes it payload
sets its own state
Think "model".
those. you have one functional that responds to all requests.
I would refactor and translate all requests to middleware and make some actions for them, like API_REQUEST, API_SUCCESS, API_ABORT, API_FAIL, etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question