withLatestFrom<S, R> method

Observable<R> withLatestFrom <S, R>(Stream<S> latestFromStream, R fn(T t, S s))

Creates an Observable that emits when the source stream emits, combining the latest values from the two streams using the provided function.

If the latestFromStream has not emitted any values, this stream will not emit either.

Interactive marble diagram

Example

new Observable.fromIterable([1, 2]).withLatestFrom(
  new Observable.fromIterable([2, 3]), (a, b) => a + b)
  .listen(print); // prints 4 (due to the async nature of streams)

Implementation

Observable<R> withLatestFrom<S, R>(
        Stream<S> latestFromStream, R fn(T t, S s)) =>
    transform(
        new WithLatestFromStreamTransformer<T, S, R>(latestFromStream, fn));