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

Zip

.zip() is an operation that combines items from two Observables into one by taking an item from each of the Observables and then producing a new value. It means that it waits for both of the Observables to produce a value before the flow continues.

This is useful in occasions where two values are produced independently but later (downstream), they are both consumed at the same time.

Let's see an example of that:

Observable.zip(        Observable.just("One", "Two", "Three"),        Observable.interval(1, TimeUnit.SECONDS),        (number, interval) -> number + "-" + interval)        .subscribe(e -> log(e));

The first argument of .zip() is this:

Observable.just("One", "Two", "Three")

This is just a regular Observable that will produce three items. The second argument ...

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