Reputation: 73
I'm trying to debounce a 100ms producer within a 1000ms window. I would expect to see the subscription being updated every 1 second with the last value emitted that period, however I am not getting anything. What am I missing here?
public static void main(String[] args) throws InterruptedException {
Observable
.interval(100, TimeUnit.MILLISECONDS)
.debounce(1000, TimeUnit.MILLISECONDS)
.subscribe(
update -> System.out.println(new Date().toString() + " " + update),
error -> System.out.println("ERROR")
);
Thread.sleep(20000);
}
Upvotes: 2
Views: 597
Reputation: 73
Found it. I was trying to find in RXJava an operator equivalent to RxJS's debounceTime(), which happen to be sample() or throttleLast().
Upvotes: 1