Kaushik Gopal - RxJava by example – Volume 3 (the multicast edition)
Why Stack Overflow recommends it
Stack Overflow users link it when answering RxJava questions about replaying the latest value, sharing a single subscription, and using replay().autoConnect().
Recommended by 2 people across 2 different months, 2018 to 2018.
What it is
Kaushik Gopal's conference talk on RxJava teaches multicasting through short, practical examples. It covers sharing work across an Android app with operators like replay, autoConnect and cache.
What people said
Recommends pratham kesarkar · 2018-01 · Stack Overflow · on “RxJava : how to get a copy of the cached data”
Suppose if you have two Subscriber out of which one subscriber want's the data as it is and the second subscriber is modifing data . Observable<String> obs =apiService.getData() .subscribeOn(ioThread()) .observeOn(mainThread()) .replay().autoConnect(); First observable to get data as it is obs.subscribe((data)->{//Do what ever}); Second Observable to modify data in some way obs.map(intenseOperation()) .subscribe((data)->{}) This way both observable will get the data and you can perform operation specific to one subscriber. In short keep all the common operation before autoconnect and perform subscriber specific task in different stream Watch the talk of This guy for understanding MultiCastin
Recommends azizbekian · 2018-03 · Stack Overflow · on “RxJava Observable that emits latest value upon subscription”
I don't want to expose a BehaviourSubject [LINK] Subject [LINK] , by definition, is "an Observer and an Observable at the same time" . Therefore, instead of exposing BehaviorSubject itself just expose Observable , thus client (in this case the view) won't be able to perform onNext() , but will be able to receive last emitted value. As an alternative to subject approach you can use replay(1).autoConnect() approach. See more details concerning this approach in "RxJava by example" presentation [this video] by Kaushik Gopal. Also, consider cache() operator (see difference of cache and replay().autoConnect() here [LINK] ).
Cites user4489210 · 2018-04 · Stack Overflow · on “replay().autoconnect() does not replay events”
I'm facing some issues with replay().autoconnect() operator combination. Before I ask my question, let me share some knowledge I have regarding this operators. I have been following this tutorial on multicasting [this video] What I understood is replay() operator can re-emit the results of the observable when a new subscriber comes in, without re-executing the source observable (Helps during network calls) autoconnect() can turn the observable into a hot observable, so that even if all the subscribers leave and later a new subscriber comes in, the observable would still be active and re-emit the results via replay() So, I found replay().autoConnect() combination would be apt for my network calls.