Another useful operator to know is .combineLatest(). It can be used to merge items from multiple Observables in a very similar way that .zip() is used, but instead of waiting for values to be produced by both the Observables, it produces new values every time one of the Observables emits an item.
When a value is produced from one of the Observable, the previous value of the other Observable is retrieved and instantly a new item from .combineLatest() is produced.
Let's explore an example:
Observable.combineLatest( Observable.just("One", "Two", "Three"), Observable.interval(1, TimeUnit.SECONDS), (number, interval) -> number + "-" + interval) .subscribe(e -> log("subscribe", e));
This will produce the following output: