February 2020
Intermediate to advanced
412 pages
9h 36m
English
If your Observable.create() is returning a long-running or infinite Observable, you should ideally check the isDisposed() method of ObservableEmitter regularly, to see whether you should keep sending emissions. This prevents unnecessary work from being done if the subscription is no longer active.
In this case, you should use Observable.range(), but for the sake of the example, let's say we are emitting integers in a for-loop in Observable.create(). Before emitting each integer, you should make sure that ObservableEmitter does not indicate that the dispose() method was called:
import io.reactivex.rxjava3.core.Observable;public class Ch2_36 { public static void main(String[] args) { Observable<Integer> ...
Read now
Unlock full access