June 2017
Intermediate to advanced
400 pages
8h 44m
English
AsyncSubject has a highly tailored, finite-specific behavior: it will only push the last value it receives, followed by an onComplete() event:
import io.reactivex.subjects.AsyncSubject;import io.reactivex.subjects.Subject;public class Launcher { public static void main(String[] args) { Subject<String> subject = AsyncSubject.create(); subject.subscribe(s -> System.out.println("Observer 1: " + s), Throwable::printStackTrace, () -> System.out.println("Observer 1 done!") ); subject.onNext("Alpha"); subject.onNext("Beta"); subject.onNext("Gamma"); subject.onComplete(); subject.subscribe(s -> System.out.println("Observer 2: " + s), Throwable::printStackTrace, () -> System.out.println("Observer 2 done!") ); }}
The output is as follows: ...
Read now
Unlock full access