flatMap<S> method

Stream<S> flatMap<S>(
  1. Stream<S> mapper(
    1. T value
    ), {
  2. int? maxConcurrent,
})

Converts each emitted item into a Stream using the given mapper function, while limiting the maximum number of concurrent subscriptions to these Streams. The newly created Stream will be be listened to and begin emitting items downstream.

The items emitted by each of the Streams are emitted downstream in the same order they arrive. In other words, the sequences are merged together.

Example

RangeStream(4, 1)
  .flatMap((i) => TimerStream(i, Duration(minutes: i)))
  .listen(print); // prints 1, 2, 3, 4

Implementation

Stream<S> flatMap<S>(Stream<S> Function(T value) mapper,
        {int? maxConcurrent}) =>
    FlatMapStreamTransformer<T, S>(mapper, maxConcurrent: maxConcurrent)
        .bind(this);