Understanding PublishSubject

PublishSubject emits all subsequent values that it got at the time of subscription, whether it got the value via the onNext method or through another subscription. We have already seen the application of PublishSubject, and it is the most commonly used Subject variant.

Here is a graphical representation of PublishSubject which has been taken from ReactiveX documentation (http://reactivex.io/documentation/subject.html):

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.