withLatestFrom2<A, B, R> method

Observable<R> withLatestFrom2 <A, B, R>(
  1. Stream<A> latestFromStream1,
  2. Stream<B> latestFromStream2,
  3. R fn(
    1. T t,
    2. A a,
    3. B b
    )
)
inherited

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

If any of latestFromStreams has not emitted any values, this stream will not emit either.

Interactive marble diagram

Example

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

Implementation

Observable<R> withLatestFrom2<A, B, R>(
  Stream<A> latestFromStream1,
  Stream<B> latestFromStream2,
  R fn(T t, A a, B b),
) =>
    transform(WithLatestFromStreamTransformer.with2(
        latestFromStream1, latestFromStream2, fn));