tapEither<X> method

ZIO<R, E, A> tapEither<X>(
  1. ZIO<R, E, X> f(
    1. Either<E, A> _
    )
)

A variant of tap, where the success and failure channels are merged into an Either.

Implementation

ZIO<R, E, A> tapEither<X>(
  ZIO<R, E, X> Function(Either<E, A> _) f,
) =>
    ZIO.from(
      (ctx) => unsafeRun(ctx).then(
        (exit) => exit
            ._matchExitFOr(
              (e) => f(Either.left(e)).unsafeRun(ctx),
              (a) => f(Either.right(a)).unsafeRun(ctx),
            )
            .then((fExit) => fExit.flatMapExit((_) => exit)),
      ),
    );