February 2020
Intermediate to advanced
412 pages
9h 36m
English
The AsyncSubject class has a highly tailored, finite-specific behavior: it pushes only the last value it receives, followed by an onComplete() event. The following snippet demonstrates this behavior:
import io.reactivex.rxjava3.subjects.AsyncSubject;import io.reactivex.rxjava3.subjects.Subject;public class Ch5_20 { 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,
Read now
Unlock full access