flatMap<B> method

ZIO<R, E, B> flatMap<B>(
  1. ZIO<R, E, B> f(
    1. A _
    )
)

Passes the success value of this ZIO to the given function, and replaces the result by executing the resulting ZIO.

Implementation

ZIO<R, E, B> flatMap<B>(
  ZIO<R, E, B> Function(A _) f,
) =>
    ZIO.from(
      (ctx) => unsafeRun(ctx).then(
        (ea) => ea.match(
          (e) => Either.left(e),
          (a) => f(a).unsafeRun(ctx),
        ),
      ),
    );