thenFlatMapEither<C> method

Future<Either<L, C>> thenFlatMapEither<C>(
  1. FutureOr<Either<L, C>> f(
    1. R value
    )
)

flatMap the Either in the Future context.

When this Future completes with a Right value, calling f callback with Right.value. And returns a new Future which is completed with the result of the call to f.

If this Future completes with a Left value, returns a Future that completes with a Left which containing original Left.value.

This function does not handle any errors. See Future.then.

Implementation

Future<Either<L, C>> thenFlatMapEither<C>(
        FutureOr<Either<L, C>> Function(R value) f) =>
    then(
      (either) => either.fold(
        ifLeft: (v) => v.left<C>(),
        ifRight: (v) => Future.sync(() => f(v)),
      ),
    );