I have a simple reducer that just sets isLoading to true when loadCounter is called and another that set it to false when loadCounterSuccess is called.
Then I have a stream that listens to the same action as the _loadCounter reducer. It just reads counter from localStorage and call _loadCounterSuccess reducer when it completes.
The isLoading state should start at false, then go to true when _loadCounter is called, then go to false again when _loadCounterSuccess is called. That's working perfectly. But the stream is calling _loadCounter reducer again when it finishes, setting isLoading to true again and exploding my app 😢
Not sure if this implementation is following this from javascript.
But if it is, then that's what they say:
REMEMBER: Epics run alongside the normal Redux dispatch channel, after the reducers have already received them. When you map an action to another one, you are not preventing the original action from reaching the reducers; that action has already been through them!
I have a simple reducer that just sets isLoading to true when
loadCounter
is called and another that set it to false whenloadCounterSuccess
is called.Then I have a stream that listens to the same action as the
_loadCounter
reducer. It just reads counter from localStorage and call_loadCounterSuccess
reducer when it completes.The
isLoading
state should start atfalse
, then go totrue
when _loadCounter is called, then go tofalse
again when_loadCounterSuccess
is called. That's working perfectly. But the stream is calling_loadCounter
reducer again when it finishes, settingisLoading
to true again and exploding my app 😢Not sure if this implementation is following this from javascript.
But if it is, then that's what they say: