Introducing the ConnectableObservable object

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() 
      connectableObservable.subscribe({ println ("Subscription ...

Get Reactive Programming in Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.