A single registered subscription, uniquely identified by (uuid, actionName).

interface SohlSubscription {
    actionName: string;
    fireAt?: number;
    oneShot?: boolean;
    payload?: Record<string, unknown>;
    predicate?: sohl.entity.expr.SafeExpression;
    sceneUuid?: string;
    triggerName: string;
    uuid: string;
}

Properties

actionName: string

The action to run, scoped to uuid. A document may have at most one subscription per action name; re-subscribing overwrites.

It is the action's shortcode, run on the owning document's logic when the subscription is offered (see SohlEventQueue.fire) — so the queue is a deferred action runner: an event reuses the very same action a user could invoke manually, on the same document.

fireAt?: number

Optional scheduled world-time. When the trigger is updateWorldTime, the subscription is due (and fires) only when ctx.worldTime >= fireAt, and due subscriptions dispatch in ascending fireAt order. Also the value returned by SohlEventQueue.nextFireTime.

oneShot?: boolean

If true, the subscription is removed immediately before its handler runs. Set by SohlEventQueue.scheduleAt.

payload?: Record<string, unknown>

Optional data attached to the subscription. On dispatch it is forwarded to the action as ctx.payload (the action context's scope).

Optional predicate expression. When present, the subscription fires only when this SafeExpression evaluates truthy against the trigger context (ctx supplies the bindings — name, worldTime, payload, …), plus subscriberUuid: this subscription's own uuid, so a predicate can compare the trigger to the document it belongs to without baking an id into its source — e.g. gating a combat turnEnd schedule to the end of the subscriber's own turn with combatant.actor.uuid === subscriberUuid. Expressions that throw are caught and logged; the dispatch is skipped but the subscription is preserved.

sceneUuid?: string

Optional uuid of the scene this subscription is bound to (issue #590). When set, a due subscription is offered only while that scene is the active scene (fvttActiveSceneUuid); while its scene is inactive the due subscription is skipped without being consumed, so it stays armed and surfaces when the scene next becomes active. Absent means the subscription is world-wide (offered regardless of the active scene).

triggerName: string

Trigger this subscription listens to (e.g. "updateWorldTime", "combatStart"). Must match the name of a SohlTriggerContext passed to SohlEventQueue.fire.

uuid: string

UUID of the document this subscription belongs to.