February 2020
Intermediate to advanced
412 pages
9h 36m
English
Remember that Maybe and Single types do not have an onNext() event, but rather an onSuccess() operator to pass a single emission. The doOnSuccess() operator usage should effectively feel like doOnNext():
import io.reactivex.rxjava3.core.Observable;public class Ch3_59 { public static void main(String[] args) { Observable.just(5, 3, 7) .reduce((total, next) -> total + next) .doOnSuccess(i -> System.out.println("Emitting: " + i)) .subscribe(i -> System.out.println("Received: " + i)); }}
The output of the preceding code snippet is as follows:
Emitting: 15Received: 15
Read now
Unlock full access