June 2017
Intermediate to advanced
400 pages
8h 44m
English
Although this may not seem useful yet, it is sometimes helpful to create an Observable that emits nothing and calls onComplete():
import io.reactivex.Observable; public class Launcher { public static void main(String[] args) { Observable<String> empty = Observable.empty(); empty.subscribe(System.out::println, Throwable::printStackTrace, () -> System.out.println("Done!")); } }
The output is as follows:
Done!
Note that no emissions were printed because there were none. It went straight to calling onComplete , which printed the Done! message in the Observer. Empty observables are common to represent empty datasets. They can also result from operators such as filter() when all emissions fail to meet a condition. Sometimes, ...
Read now
Unlock full access