withLatestFrom<S, R> method

Observable<R> withLatestFrom<S, R>(
  1. Stream<S> latestFromStream,
  2. R fn(
    1. T t,
    2. 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


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)


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