then<R extends Object> method
Async<R>
then<
R extends Object>( - @noFutures R noFutures(
- T value
)
)
override
Implementation
@override
@pragma('vm:prefer-inline')
Async<R> then<R extends Object>(@noFutures R Function(T value) noFutures) {
// Route through `Async(() async {...})` so a synchronous throw from
// `noFutures` is captured as an Err on the chain instead of escaping to
// whoever awaits the resulting Async.
return Async<R>(() async {
final result = await value;
switch (result) {
case Ok(value: final v):
return noFutures(v);
case final Err err:
throw err;
}
});
}