February 2020
Intermediate to advanced
412 pages
9h 36m
English
A close cousin of Observable.empty() is Observable.never(). The only difference between them is that the never() method does not generate the onComplete event, thus leaving the observer waiting for an emission forever:
import io.reactivex.rxjava3.core.Observable;public class Ch2_21 { public static void main(String[] args) { Observable<String> empty = Observable.never(); empty.subscribe(System.out::println, Throwable::printStackTrace, () -> System.out.println("Done!")); sleep(3000); }}
This Observable is primarily used for testing and not that often in production. We have to use sleep() here just like Observable.interval() because the main thread is not going to wait for it after kicking it off. In this case, we just use ...
Read now
Unlock full access