FutureToResultX<T> extension
Bridges a regular Future<T> (which signals failure by throwing) into a
Future<Result<T>> without writing Result.tryRunAsync(() => future) at
every call site.
Named asResult (rather than toResult) to avoid colliding with the
transport-specific .toResult() methods provided by the retrofit /
chopper integration barrels.
- on
-
- Future<
T>
- Future<
Methods
-
asResult(
{Failure onError(Object error, StackTrace stackTrace)?}) → Future< Result< T> > -
Available on Future<
Awaits this future, returning Success on completion or Error if it throws. By default the caught object is wrapped in Failure.unknown; passT> , provided by the FutureToResultX extensiononErrorto translate transport-specific exceptions into a more meaningful Failure.