wrapAsync<T> static method

Future<Maybe<T>> wrapAsync<T>(
  1. Future<T> compute()
)

Compute a Future value using compute and wrap the result in a Maybe.

  1. compute is called to compute a Future value.
  2. The Future is awaited.
  3. The result is wrapped in a Maybe as if by Maybe.wrap

Implementation

static Future<Maybe<T>> wrapAsync<T>(Future<T> Function() compute) async {
  try {
    return Maybe(await compute());
  }
  catch (e, trace) {
    return Maybe.error(e, trace);
  }
}