February 2020
Intermediate to advanced
412 pages
9h 36m
English
The doFinally() operator is executed when onComplete(), onError(), or disposal happens. It is executed under the same conditions as doAfterTerminate(), plus it is also executed after the disposal. For example, look at the following code:
import io.reactivex.rxjava3.core.Observable;public class Ch3_60 { public static void main(String[] args) { Observable.just("One", "Two", "Three") .doFinally(() -> System.out.println("doFinally!")) .doAfterTerminate(() -> System.out.println("doAfterTerminate!")) .subscribe(i -> System.out.println("Received: " + i)); }}
The output is as follows:
Received: OneReceived: TwoReceived: ThreedoAfterTerminate!doFinally!
Now, let's see how they work when dispose() is called:
import io.reactivex.rxjava3.core.Observable ...Read now
Unlock full access