combineWith method

ValueStream<Iterable<X>> combineWith(
  1. Iterable<ValueStream<Iterable<X>>> others, [
  2. String? debugName
])

Implementation

ValueStream<Iterable<X>> combineWith(Iterable<ValueStream<Iterable<X>>> others, [String? debugName]) {
  /// Ensures that the ValueStream emits
  // ignore: avoid_shadowing_type_parameters
  Stream<X> flatten<X>(ValueStream<X> input) {
    return Stream.fromFuture(Future.value(input.get())).expectNotNull().merge(input.after);
  }

  Stream<Iterable<X>> stream = flatten(this).combineLatestAll(others.map((o) => flatten(o))).map((all) {
    return [
      ...all.expand((_) => _),
    ];
  });

  return ValueStream<Iterable<X>>.of([], stream, this.debugName);
}