Open wagcampbell opened 5 years ago
yes, throttle should be added.
it may be possible to use window_trigger
, first
, debounce
to get the first item instead of the last. something like this:
auto throttle = [](auto time){
return [time](auto in){
auto s = in.publish().ref_count();
return s.
window_trigger(s.debounce(time)).
transform([](auto w){return w.first();})).
switch_on_next();
};
};
Very nice!
I wonder how one could make such custom throttle
operator pipable as the other built-in operators?
auto sub = rxcpp::observable<>::interval(std::chrono::steady_clock::now(), std::chrono::milliseconds(100), rxcpp::observe_on_new_thread())
| throttle(std::chrono::milliseconds(400))
| subscribe<long>([](...) { /* ... */ });
Thanks! :)
The current implementation is missing the throttle operator.
The closest I could find is the debounce operator. However, one difference is that the debounce operator will emit the last item in a series of items while throttle will emit the first.
Is there an equivalent operator or combination that will produce the same result?