withLatestFrom<S, R> method

Stream<R> withLatestFrom<S, R>(
  1. Stream<S> latestFromStream,
  2. R fn(
    1. T t,
    2. S s

Creates a Stream 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


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


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