ReactiveX / RxCpp

Reactive Extensions for C++
Apache License 2.0
3.03k stars 390 forks source link

Add throttle operator #515

Open cmd-johnson opened 4 years ago

cmd-johnson commented 4 years ago

I'm used to RxJS and loved the concept, so I wanted to use it in C++ as well. Seeing #501, I thought this would be a good opportunity for me to get a little deeper into understanding the implementation of RxCpp.

This is mostly a copy&paste of the debounce operator implementation, edited to implement throttle semantics (ref. RxJS).

The throttle operator re-emits the first value emitted by the source, then swallows all following emissions until the specified timeout has occurred. After that, the next value emitted by the source is emitted again and the cycle continues.

The RxJS implementation also supports emitting the last value emitted by the source when the timeout completes. If this is a feature you would like to see, I can add support for that as well.

cmd-johnson commented 4 years ago

Hmmm, not quite sure why the Travis build fails. It's only one and it fails to install g++-8, which all other runners have had no problems with.

antekone commented 3 years ago

Any news on this PR? Could throttle be included in RxCpp?