Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the Flux equivalents of debounce, throttleFirst, and throttleLast

debounce, throttleFirst, and throttleLast are most conspicuously absent from Project Reactor's Flux. Do they have any counterparts?

like image 340
Victor Grazi Avatar asked Jun 18 '17 17:06

Victor Grazi


2 Answers

The sample operators are the once relating to the behavior you're searching for.

sampleTimeout could be used as debounce.
sampleFirst could be used as throttleFirst.
sample could be used as throttleLast.

like image 149
tynn Avatar answered Nov 16 '22 06:11

tynn


I've been struggling to understand how to use sampleTimeout to do a debounce so I though I would put it here in case someone else is looking for this:

The would be equivalent to a debounce of 200ms

myFlux.sampleTimeout(u -> Mono.empty().delaySubscription(Duration.ofMillis(200)))
like image 1
Crystark Avatar answered Nov 16 '22 05:11

Crystark