effect-io-ai

Package: effect
Module: Latch

Latch.whenOpen

Waits on the latch, then runs the provided effect.

When to use

Use to gate another effect so it starts only after the latch is opened or the current waiters are released.

Details

If the latch is open, the effect runs immediately. If it is closed, the returned effect suspends until the latch is opened or the current waiters are released. The provided effect’s success, failure, and requirements are preserved.

See

Signature

declare const whenOpen: { (self: Latch): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>; <A, E, R>(self: Latch, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>; }

Source

Since v4.0.0