June 2017
Intermediate to advanced
400 pages
8h 44m
English
The throttleFirst() operates almost identically to throttleLast(), but it will emit the first item that occurs at every fixed time interval. If we modify our example to throttleFirst() every 1 second, we should get an output like this:
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, then 2000, followed by 4000. The 4000 was emitted right on the cusp of ...
Read now
Unlock full access