zip2<A, B, T> method

Observable<T> zip2 <A, B, T>(Stream<A> streamA, Stream<B> streamB, T zipper(A a, B b))

Merges the specified streams into one observable sequence using the given zipper function whenever all of the observable sequences have produced an element at a corresponding index.

It applies this function in strict sequence, so the first item emitted by the new Observable will be the result of the function applied to the first item emitted by Observable #1 and the first item emitted by Observable #2; the second item emitted by the new zip-Observable will be the result of the function applied to the second item emitted by Observable #1 and the second item emitted by Observable #2; and so forth. It will only emit as many items as the number of items emitted by the source Observable that emits the fewest items.

Interactive marble diagram

Example

Observable.zip2(
  new Observable.just("Hi "),
  new Observable.fromIterable(["Friend", "Dropped"]),
  (a, b) => a + b)
.listen(print); // prints "Hi Friend"

Implementation

static Observable<T> zip2<A, B, T>(
        Stream<A> streamA, Stream<B> streamB, T zipper(A a, B b)) =>
    Observable<T>(ZipStream.zip2(streamA, streamB, zipper));