February 2020
Intermediate to advanced
412 pages
9h 36m
English
The timeInterval( ) operator emits the time lapses between the consecutive emissions of a source Observable. Here is an example:
import io.reactivex.rxjava3.core.Observable;import java.util.concurrent.TimeUnit;public class Ch3_69 { public static void main(String[] args) { Observable.interval(2, TimeUnit.SECONDS) .doOnNext(i -> System.out.println("Emitted: " + i)) .take(3) .timeInterval(TimeUnit.SECONDS) .subscribe(i -> System.out.println("Received: " + i)); sleep(7000); }}
The output is as follows:
Emitted: 0Received: Timed[time=2, unit=SECONDS, value=0]Emitted: 1Received: Timed[time=2, unit=SECONDS, value=1]Emitted: 2Received: Timed[time=2, unit=SECONDS, value=2]
And we can unwrap the values the same way we did for the ...
Read now
Unlock full access