Interfacecorev0.14.0
Gate
A precondition attached to a handler. It refuses by throwing a Notice (a reply) or a Silence
(no reply), and passes by returning. Ctx is the context it requires, so a gate that reads
a field absent on a handler's context is rejected at compile time. Name is captured as a literal so
a mismatch error can show the gate's name. Build one with defineGate or defineEffectGate.
See also:defineGate
interface Gate<
Ctx extends GateContextBase = GateContextBase,
Name extends string = string
>// a factory returning a typed, agnostic gate
function MyGate(): Gate<GateContextBase, 'MyGate'> {
return defineGate('MyGate', (ctx) => {
if (shouldRefuse(ctx)) throw new MyNotice();
});
}Ctx
The context that the gate requires. A field missing from it is a compile error.
Ctx extends GateContextBase = GateContextBaseName
The gate's literal name, named in a mismatch error.