February 2020
Intermediate to advanced
412 pages
9h 36m
English
An interesting and possibly helpful kind of Subject is the UnicastSubject class. Like any Subject, it can be used to observe and subscribe to the sources. In addition, it buffers all the emissions it receives until an Observer subscribes to it, and then it releases all the emissions to the Observer and clears its cache. The following snippet demonstrates the behavior described:
import io.reactivex.rxjava3.core.Observable;import io.reactivex.rxjava3.subjects.Subject;import io.reactivex.rxjava3.subjects.UnicastSubject;import java.util.concurrent.TimeUnit;public class Ch5_21 { public static void main(String[] args) { Subject<String> subject = UnicastSubject.create(); Observable.interval(300, TimeUnit.MILLISECONDS) .map(l -> ((l ...
Read now
Unlock full access