combineOutcome<T extends Object> function

Resolvable<List<Option<T>>> combineOutcome<T extends Object>(
  1. Iterable<Outcome<T>> outcomes, {
  2. @noFutures Err<List<Option<T>>> onErr(
    1. List<Result<Option<T>>> allResults
    )?,
})

Combines an iterable of Outcomes into one containing a list of their values.

The result is an Async if any of the outcomes are Async If any resolvable contains an Err, applies onErr to combine errors.

Implementation

Resolvable<List<Option<T>>> combineOutcome<T extends Object>(
  Iterable<Outcome<T>> outcomes, {
  @noFutures
  Err<List<Option<T>>> Function(List<Result<Option<T>>> allResults)? onErr,
}) {
  final reduced = outcomes.map((e) => e.reduce<T>());
  return combineResolvable<Option<T>>(reduced, onErr: onErr);
}