merge<T> static method

Stream<T> merge<T>(
  1. List<Stream<T>> streams
)

Merges list of stream into one stream

Implementation

static Stream<T> merge<T>(List<Stream<T>> streams) {
  var _open = streams.length;
  final streamController = StreamController<T>();
  for (final stream in streams) {
    stream.listen(streamController.add)
      ..onError(streamController.addError)
      ..onDone(() {
        if (--_open == 0) {
          streamController.close();
        }
      });
  }
  return streamController.stream;
}