redux-saga icon indicating copy to clipboard operation
redux-saga copied to clipboard

Throttle channel

Open twiggler opened this issue 5 years ago • 8 comments

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.

twiggler avatar Mar 03 '19 12:03 twiggler

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

mshustov avatar Mar 03 '19 13:03 mshustov

No problem. Should I create a pull request for fixing the mistake in the docs, or are you going to remove it?

twiggler avatar Mar 04 '19 09:03 twiggler

would be great to try to implement it. ideally all effects should work in the same way

mshustov avatar Mar 19 '19 07:03 mshustov

@restrry I will give it a shot

twiggler avatar Mar 21 '19 09:03 twiggler

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.

twiggler avatar Apr 05 '19 20:04 twiggler

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.

neurosnap avatar Feb 27 '22 04:02 neurosnap

just ran into this today any good user land workarounds? 👀

rssfrncs avatar Aug 31 '22 11:08 rssfrncs

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.

neurosnap avatar Sep 01 '22 16:09 neurosnap

TypeScript has definitions to pass a Channel to throttle too, but crashes at runtime.

Please we need a fix, it's very confusing

isc30 avatar Nov 16 '22 12:11 isc30

@isc30 I'll add this to the top of my list

neurosnap avatar Nov 16 '22 19:11 neurosnap

Hey @neurosnap thanks, I'm also happy to drop a PR sometime tomorrow if that helps

isc30 avatar Nov 16 '22 19:11 isc30

Hey thanks, I'm also happy to drop a PR sometime tomorrow if that helps

isc30 avatar Nov 16 '22 19:11 isc30