December 2017
Intermediate to advanced
322 pages
7h 3m
English
It is more like Cold Observable; it will replay all the items it got, regardless of when Observer subscribes.
Here is the graphical representation:

Image credit: http://reactivex.io/documentation/subject.html
Let's modify the previous program with ReplaySubject:
fun main(args: Array<String>) { val subject = ReplaySubject.create<Int>() subject.onNext(1) subject.onNext(2) subject.onNext(3) subject.onNext(4) subject.subscribe({ //onNext println("S1 Received $it") },{ //onError it.printStackTrace() },{ //onComplete println("S1 Complete") }) subject.onNext(5) subject.subscribe({ //onNext println("S2 Received $it") },{ ...Read now
Unlock full access