June 2017
Intermediate to advanced
400 pages
8h 44m
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 a disposal was called:
import io.reactivex.Observable; public class Launcher { public static void main(String[] args) { Observable<Integer> source = Observable ...
Read now
Unlock full access