O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Multiple sources

However, what will happen when there are multiple sources? Let's examine this example:

Subject<Long> subject = PublishSubject.create();Observable.interval(2, TimeUnit.SECONDS)        .take(3)        .doOnComplete(() -> log("Origin-One-doOnComplete"))        .subscribe(subject);Observable.interval(1, TimeUnit.SECONDS)        .take(2)        .doOnComplete(() -> log("Origin-Two-doOnComplete"))        .subscribe(subject);subject        .doOnComplete(() -> log("First-doOnComplete"))        .subscribe(v -> log(v));

Here, there are two Observables. The first is this:

Observable.interval(2, TimeUnit.SECONDS)

The second one is as following:

Observable.interval(1, TimeUnit.SECONDS)

They are emitting values to the Subject (or rather Subject listens to them), but we can see that the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required