February 2020
Intermediate to advanced
412 pages
9h 36m
English
The throttleFirst() operates almost identically to throttleLast(), but it emits the first item that occurs at every fixed time interval. Let's modify our example to throttleFirst() every 1 second as follows:
Observable.concat(source1, source2, source3) .throttleFirst(1, TimeUnit.SECONDS) .subscribe(System.out::println);
The output is as follows:
SOURCE 1: 100SOURCE 2: 300SOURCE 3: 2000SOURCE 3: 4000
Effectively, the first emission found after each interval starts is the emission that gets pushed through. The 100 from source1 was the first emission found on the first interval. On the next interval, 300 from source2 was emitted, and then 2,000, followed by 4,000. The 4,000 was emitted right on the cusp of the application quitting, ...
Read now
Unlock full access