Package: effect
Module: Effect
Runs the cleanup effect only when the Exit satisfies the provided
predicate.
Example (Observing selected exits)
import { Console, Effect, Exit } from "effect"
const program = Effect.onExitIf(
Effect.succeed(42),
Exit.isSuccess,
(exit) =>
Exit.isSuccess(exit)
? Console.log(`Succeeded with: ${exit.value}`)
: Effect.void
)
Signature
declare const onExitIf: { <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>; <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>; }
Since v4.0.0