Can I make yield take(chan, ‘SOME_ACTION’) working?
See original GitHub issueHello everyone!
We use redux-saga extensively and love this great and superb library 😃 We utilize a lot of channels to communicate between many sagas and write code like this:
yield take(chan, ‘SOME_ACTION’)
.
At first we thought that take effect is able to handle invocation with two arguments channel and pattern because:
function runTakeEffect({channel, pattern, maybe}, cb)
But this is partly true. It’s works if channel was empty when we yielded take effect. In this case taker was pushed into takers array and it will be called with accordance to matching pattern when action is put into channel. But if the buffer is not empty then taker is invoked immediately with first element from buffer ignoring pattern at all.
How can we workaround this problem and get only certain actions from the channel using yield take(chan, ‘SOME_ACTION’)
?
@yelouafi How do you think about including such behavior into the lib? Maybe iterate over buffer to return action that is matched to pattern?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top GitHub Comments
It’s almost the same,
stdChannel
has slightly different scheduling - it is only supposed to be used as ‘top-level’ channel withrunSaga
API.Hey @Andarist, sorry for the delay… Busy week at work.j
I couldn’t find much about
multicastChannel
around. What is the difference betweenstdChannel
andmulticastChannel
?