redux-saga
redux-saga copied to clipboard
Throttle channel
The documentation states that it is possible to pass a channel to throttle
.
However, when I do the following:
const progressChan = yield channel(buffers.sliding(.));
...
yield throttle(., progressChan, ...)
actionChannel borks about an invalid pattern.
Sorry, that's mistake in docs. Right now it works only with pattern. Need to support a channel as well https://github.com/redux-saga/redux-saga/blob/master/packages/core/src/internal/sagaHelpers/throttle.js
No problem. Should I create a pull request for fixing the mistake in the docs, or are you going to remove it?
would be great to try to implement it. ideally all effects should work in the same way
@restrry I will give it a shot
Some thoughts about implementing this:
Throttling actions is currently implemented using an actionmap
. There is no guarantee when throttling a channel that the channel to be throttled is created with a sliding buffer of size 1. One method which works with any channel buffer is to take
one and then flush
the channel.
Unfortunately in this case the throttle
operation is backed by two possible implementations, depending if the supplied argument is a pattern or channel. If we accept a superfluous flush
on the actionchannel in case of throttling a pattern, both implementations are almost identical.
Closing due to inactivity. I realize this is a feature request but since there hasn’t been any activity in years, I’m going to assume it’s not a hotly desired feature. If this is a wrong assumption, I’d be happy to reopen and continue to discuss.
just ran into this today any good user land workarounds? 👀
Hi @rssfrncs
Sorry for the late response. I haven't had time to investigate adding throttling to our channels. In theory it should be possible. I don't know of any workarounds at this point but I'll spend some time this weekend looking into it.
I'm going to reopen this issue.
TypeScript has definitions to pass a Channel to throttle
too, but crashes at runtime.
Please we need a fix, it's very confusing
@isc30 I'll add this to the top of my list
Hey @neurosnap thanks, I'm also happy to drop a PR sometime tomorrow if that helps
Hey thanks, I'm also happy to drop a PR sometime tomorrow if that helps