Forward Rx items with a cooldown, switching to sampling when they come too fast

Viewed 775

I'm looking for the Rx method that will take an observable and put the latest item on a 'cooldown', so that when items are coming in slower than the cooldown they're just forwarded but when they're coming in faster you just get the latest value after each cooldown period.

Said a different way, I want to switch to sampling with period t when items are separated by less than t time (and switch back when they're spread out).

This is really similar to what Observable.Throttle does, except that the timer is not reset whenever a new item arrives.

The application I have in mind is for sending 'latest value' updates across the network. I don't want to communicate a value unless it has changed, and I don't want to spam a rapidly changing value so much that I swamp out other data.

Is there a standard method that does what I need?

4 Answers
Related