flatMapAsync<R> method

  1. @override
FutureOr<Result<R>> flatMapAsync<R>(
  1. Future<R> onSuccess(
    1. T value
    ), {
  2. ExceptionHandler? exceptionHandler,
  3. String? errorGroup,
})
override

Similar to flatMap, but for asynchronous operations. Maps a Result<T> to FutureOr<Result<R>>.

onSuccess is the function that asynchronously transforms the value if the result is a success. exceptionHandler is an optional handler for any exceptions thrown during the transformation. errorGroup is an optional group identifier for the error.

Implementation

@override
FutureOr<Result<R>> flatMapAsync<R>(
  Future<R> Function(T value) onSuccess, {
  ExceptionHandler? exceptionHandler,
  String? errorGroup,
}) =>
    Result.fromAsync(
      () => onSuccess(_value),
      exceptionHandler: exceptionHandler,
      errorGroup: errorGroup,
    );