zipWith<S, R> method

Stream<R> zipWith<S, R>(
  1. Stream<S> other,
  2. R zipper(
    1. T t,
    2. S s
    )
)

Returns a Stream that combines the current stream together with another stream using a given zipper function.

Example

Stream.fromIterable([1])
    .zipWith(Stream.fromIterable([2]), (one, two) => one + two)
    .listen(print); // prints 3

Implementation

Stream<R> zipWith<S, R>(Stream<S> other, R Function(T t, S s) zipper) {
  final stream = ZipStream.zip2(this, other, zipper);

  return isBroadcast
      ? stream.asBroadcastStream(onCancel: (s) => s.cancel())
      : stream;
}