December 2017
Intermediate to advanced
322 pages
7h 3m
English
A great example of Hot Observables is ConnectableObservable. It is one of the most helpful forms of Hot Observables as well. It can turn any Observable, even a Cold Observable, into a Hot Observable. It doesn't start emitting on the subscribe call; instead, it gets activated after you call the connect method. You have to make the subscribe calls before calling connect; any subscribe calls after calling connect will miss the emissions fired previously.
Let's consider the following code snippet:
fun main(args: Array<String>) {
val connectableObservable = listOf ("String 1","String 2","String 3","String 4","String 5").toObservable()
.publish()//1
connectableObservable.subscribe({ println ("Subscription ...Read now
Unlock full access