resolveAllJoined<R> method

FutureOr<R> resolveAllJoined<R>(
  1. FutureOr<R> joiner(
    1. List<T> r
    )
)

Resolves all elements and join them with joiner.

Implementation

FutureOr<R> resolveAllJoined<R>(FutureOr<R> Function(List<T> r) joiner) {
  var self = this;

  if (_isNotFuture(T) && self is Iterable<T>) {
    var l = self.toList();
    return joiner(l);
  }

  var all = allAsList;
  if (all.isEmpty) return joiner(<T>[]);

  if (all.isAllResolved) {
    var l = all.cast<T>();
    return joiner(l);
  } else {
    return Future.wait(all.asFutures).resolveMapped(joiner);
  }
}