June 2017
Intermediate to advanced
400 pages
8h 44m
English
An interesting and possibly helpful kind of Subject is UnicastSubject. A UnicastSubject, like all Subjects, will be used to observe and subscribe to the sources. But it will buffer all the emissions it receives until an Observer subscribes to it, and then it will release all these emissions to the Observer and clear its cache:
import io.reactivex.Observable;import io.reactivex.subjects.ReplaySubject;import io.reactivex.subjects.Subject;import io.reactivex.subjects.UnicastSubject;import java.util.concurrent.TimeUnit;public class Launcher { public static void main(String[] args) { Subject<String> subject = UnicastSubject.create(); Observable.interval(300, TimeUnit.MILLISECONDS) .map(l -> ((l + 1) * 300) + " milliseconds") .
Read now
Unlock full access