resolveAllMapped<R> method

FutureOr<List<R>> resolveAllMapped<R>(
  1. R mapper(
    1. T e
    )
)

Resolves all elements and map them with mapper.

Implementation

FutureOr<List<R>> resolveAllMapped<R>(R Function(T e) mapper) {
  var self = this;

  if (_isNotFuture(T) && self is Iterable<T>) {
    return self.map(mapper).toList();
  }

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

  if (all.isAllResolved) {
    return all.cast<T>().map(mapper).toList();
  } else {
    return Future.wait(all.asFutures).then((l) {
      return l.map(mapper).toList();
    });
  }
}