combineMonad<T extends Object> function
Combines an iterable of Monads into one containing a list of their values.
The result is an Async if any of the monads
are Async
If any resolvable contains an Err, applies onErr
to combine errors.
Implementation
Resolvable<List<Option<T>>> combineMonad<T extends Object>(
Iterable<Monad<T>> monads, {
@noFutures
Err<List<Option<T>>> Function(List<Result<Option<T>>> allResults)? onErr,
}) {
final reduced = monads.map((e) => e.reduce<T>());
return combineResolvable<Option<T>>(reduced, onErr: onErr);
}