defineEffectGate
Builds an EffectGateEffectGate from a checkcheck and a commitcommit. checkcheck peeks and refuses by throwing, and commitcommit applies the side effect, running only once the whole gate set passes so a later refusal never commits. In an oror, a refusing arm's queued commit is rolled back. This is how CooldownCooldown peeks in checkcheck and charges the slot in commitcommit.
See also:defineGate, Gated, Cooldown
defineEffectGate<Name, Ctx>(
name: Name,
check: (ctx: Ctx) => void | Promise<void>,
commit: (ctx: Ctx) => void | Promise<void>
): EffectGate<Ctx, Name>defineEffectGate<Name, Ctx>(
name: Name,
check: (ctx: Ctx) => void | Promise<void>,
commit: (ctx: Ctx) => void | Promise<void>
): EffectGate<Ctx, Name>Name
The gate's name captured as a literal, so a mismatch error can name the gate.
NameNameThe gate's name captured as a literal, so a mismatch error can name the gate.
Ctx
The context both checkcheck and commitcommit read, inferred from the ctxctx annotation.
CtxCtxThe context both checkcheck and commitcommit read, inferred from the ctxctx annotation.
name
name: Namename: NameThe gate's name, used in mismatch errors.