throttle First
Emits a value, then ignores new values until window has passed. For taps and other bursts.
The first value passes at once. Values that arrive in the next window are dropped. After the window, the next value passes and starts a new window.
Example
buttonClicks.throttleFirst(500.milliseconds).collect { submitOrder() }
// Taps at 0 ms, 100 ms and 700 ms submit twice: at 0 ms and at 700 ms.Content copied to clipboard
Compared with debounce and sample
debounce waits for a quiet period and then emits the last value. sample emits the latest value once per period. throttleFirst emits the first value at once.
Watch out
Dropped values are lost. After the window, the next new value passes, not the last dropped value.
The window starts when the collector has finished with the emitted value. A slow collector makes the effective window longer.
Parameters
window
how long to drop values after each emitted value. Must be positive.
Throws
if window is zero or negative.