TriggerCtx
The single argument every trigger handler receives. It bundles the matching event, a conditions snapshot, the actions proxy, the check DSL, runtime metadata and an AbortSignal. The shape is fully derived from the trigger’s TriggerSchema — destructure the fields you need.
Import
Section titled “Import”Definition
Section titled “Definition”S is the trigger’s schema; R is the union of required condition keys (required: [...] in the config).
Fields
Section titled “Fields”event — EventOf<S>
Section titled “event — EventOf<S>”Discriminated union over S['events']. Each variant has { readonly name: K; readonly payload: EventMap<S>[K] }. Narrow with event.name.
conditions — ConditionsCtx<ConditionMap<S>, R>
Section titled “conditions — ConditionsCtx<ConditionMap<S>, R>”Snapshot of all conditions, captured once at fire time. Keys listed in required appear as non-optional; others are T | undefined.
V1 limitation: required does not narrow in the type system — conditions.user stays User | undefined even when required: ['user']. Use check.is/all/any or an early if (!conditions.user) return; guard.
actions — ActionsCtx<ActionMap<S>>
Section titled “actions — ActionsCtx<ActionMap<S>>”Map of { [name]?: (payload) => void } plus three chainable timers:
| Method | Returns | Description |
|---|---|---|
actions.<name>?.(payload) | void | Invoke an action if it’s registered. Optional chain because no reactor may be mounted. |
actions.debounce(ms) | same shape | Wait until ms of silence before firing. |
actions.throttle(ms) | same shape | At most one fire per ms window. |
actions.defer(ms) | same shape | Wait ms before firing — no coalescing. |
check — CheckCtx<ConditionMap<S>>
Section titled “check — CheckCtx<ConditionMap<S>>”The predicate DSL. See createCheck. is, all, and any all NonNullable-narrow the value inside the predicate.
meta — MetaCtx
Section titled “meta — MetaCtx”Runtime metadata about the current run:
| Field | Type | Description |
|---|---|---|
runId | string | Unique per-run id. |
triggerId | string | The trigger that’s running. |
scheduledAt | number | performance.now() when the run was enqueued. |
cascadeDepth | number | 0 for top-level fires; n for the n-th cascade child. |
parentRunId? | string | Set when the run is part of a cascade. |
parentTriggerId? | string | Same — id of the upstream trigger. |
signal — AbortSignal
Section titled “signal — AbortSignal”Aborts when the runtime cancels the current run — e.g. a take-latest concurrency strategy supersedes it, the trigger is disabled or disposed, or the runtime itself is torn down. Pass it into fetch(url, { signal }), addEventListener('…', fn, { signal }), or check signal.aborted after any async wait.