asyncOf<T extends Object, E extends Object> static method

Future<Result<T, E>> asyncOf<T extends Object, E extends Object>(
  1. Future<T> catching()
)

Call the catching function and produce a Future<Result<T, E>>.

see also:

  • Result.of

Implementation

static Future<Result<T, E>> asyncOf<T extends Object, E extends Object>(
  Future<T> Function() catching,
) async {
  try {
    return Ok(await catching());
  } on E catch (e) {
    return Err(e);
  }
}