February 2020
Intermediate to advanced
412 pages
9h 36m
English
The onComplete() operator allows you to fire off an action when an onComplete event is emitted at the point in the Observable chain. This can be helpful in seeing which points of the Observable chain have completed, as shown in the following code snippet:
import io.reactivex.rxjava3.core.Observable;public class Ch3_52 { public static void main(String[] args) { Observable.just("Alpha", "Beta", "Gamma") .doOnComplete(() -> System.out.println("Source is done emitting!")) .map(String::length) .subscribe(i -> System.out.println("Received: " + i)); }}
The output of the preceding code snippet is as follows:
Received: 5Received: 4Received: 5Source is done emitting!
And, of course, onError() will peek at the error ...
Read now
Unlock full access