remove Channels from the reduxStore implementation #143
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces the internal usages of channels by just merging the upstream actions and the actions emitted by side effects into one flow that than is collected. I'm not sure about all the issues that we had in the past before going to
select
andonReceive
but back then we also usedlaunch
internally which we don't need here. Also collecting aFlow
inside theflow {}
builder is fine, so I think this implementation should work.There is one behavior change. Previously we had essentially 2+ action queues, one for actions coming from upstream and one each for actions emitted by each side effect. The side effect action queues were always handled first and only if they were empty we would look at the next upstream action. Also within the side effects there was strict ordering by side effects (essentially the first side effect could starve all others by handling each action, including its own and always emitting a new action in response).
Now there is just one queue were actions from everywhere are put it in. Since by default there is no concurrency in the store these are still ordered. So if there is an upstream action and each side effect immediately emits another action in response to that the side effect action will still arrive in the order of the side effects like before. So this does not introduce randomness.
The behavior change can be seen in the tests. With the now uncommented
delay(10)
instore with 2 simple side effects
the test behaves like before. Without the delay (the addedstore with 2 simple side effects no delay
test) the upstream2
action reaches the reducer before the side effect actions because it was first in the shared queue of actions.