February 2020
Intermediate to advanced
412 pages
9h 36m
English
A helpful form of a hot Observable is the ConnectableObservable class. It takes any Observable, even if it is cold, and makes it hot so that all emissions are played to all observers at once. To do this conversion, you simply need to call publish() on an Observable, and it will yield a ConnectableObservable object.
But note that subscribing does not start the emission. You need to call the connect() method on the ConnectableObservable object to start it. This allows you to set up all your observers first, before the first value is emitted.
Take a look at the following code snippet:
import io.reactivex.rxjava3.core.Observable;import io.reactivex.rxjava3.observables.ConnectableObservable;public class Ch2_14 { public static ...
Read now
Unlock full access