combineAll<T> static method

MergedStream<T, List<T>> combineAll<T>(
  1. Iterable<Stream<T>> streams
)

Implementation

static MergedStream<T, List<T>> combineAll<T>(
        final Iterable<Stream<T>> streams) =>
    MergedStream(streams, () {
      final latest = List<T?>.filled(streams.length, null, growable: false);
      var count = 0;
      return (c) {
        if (latest[c.index] == null) {
          latest[c.index] = c.value;
          if (++count == latest.length) {
            count = 0;
            c.add(latest.cast<T>().toList(growable: false));
            for (int i = 0; i < latest.length; i++) {
              latest[i] = null;
            }

            c.resume();
          } else {
            c.currentSubscription.pause();
          }
        }
      };
    });