flatMap<R extends Object> method
Chains another Resolvable-producing operation: the monadic bind for
Resolvable. If this is in an Err state, the chain short-circuits
with that Err. If noFutures throws, the throw is absorbed into an
Err.
Equivalent to .then(...) followed by .flatten(), with the
short-circuit and throw-absorption wired in.
Implementation
@override
@pragma('vm:prefer-inline')
Async<R> flatMap<R extends Object>(
@noFutures Resolvable<R> Function(T value) noFutures,
) {
return Async<R>(() async {
final result = await value;
switch (result) {
case Ok(value: final v):
return await noFutures(v).unwrap();
case final Err<T> err:
throw err;
}
});
}