fromFuture<T, E> static method

ResultAsync<T, E> fromFuture<T, E>(
  1. Future<T> future,
  2. E errorFn(
    1. Object e
    )
)

Implementation

static ResultAsync<T, E> fromFuture<T, E>(
    Future<T> future, E Function(Object e) errorFn) {
  final newFuture = future
      .then<Result<T, E>>((value) => Ok<T, E>(value))
      .catchError((e) => Err<T, E>(errorFn(e)));

  return ResultAsync(newFuture);
}