flatMapNullableOrFail<B> method

ZIO<R, E, B> flatMapNullableOrFail<B>(
  1. B? f(
    1. A _
    ),
  2. E onNull(
    1. A _
    )
)

A variant of flatMap that determines the result of the ZIO by evaluating the resulting nullable value.

If the value is null, the resulting ZIO will fail with onNull.

Implementation

ZIO<R, E, B> flatMapNullableOrFail<B>(
  B? Function(A _) f,
  E Function(A _) onNull,
) =>
    flatMapEither((a) => Either.fromNullable(f(a), () => onNull(a)));