Interfacecorev0.14.0
EffectGate
A gate whose check method can refuse a request without applying its side effect. commit applies
the effect after every gate passes. Cooldown is the catalog gate that returns one. Build one with
defineEffectGate.
See also:defineEffectGate
interface EffectGate<
Ctx extends GateContextBase = GateContextBase,
Name extends string = string
> extends Gate<Ctx, Name>// a factory returning a typed effect gate
function MyEffectGate(): EffectGate<GateContextBase, 'MyEffectGate'> {
return defineEffectGate(
'MyEffectGate',
(ctx) => {
if (shouldRefuse(ctx)) throw new MyNotice();
},
(ctx) => {
applyMyEffect(ctx);
}
);
}Ctx
The context both check and commit require. A field missing from it fails to compile.
Ctx extends GateContextBase = GateContextBaseName
The literal name a mismatch error prints.
readonly name: NameInherited from:Gate