Skip to content

EventRegistry

Defined in: core/src/event/event.registry.ts:33

Registry of Event types (keyed by id) plus the emitter used to publish and subscribe to their occurrences. Publishing emits both the event’s own id and a wildcard event channel.

The wildcard channel is never filtered: it is how a host observes everything a provider emits. Filtering applies to subscribe, which is per event type.

new EventRegistry(): EventRegistry;

Defined in: core/src/event/event.registry.ts:37

EventRegistry

get emitter(): EventEmitter<EventRegistryEvents>;

Defined in: core/src/event/event.registry.ts:43

The underlying emitter, exposed for wiring event forwarding.

EventEmitter<EventRegistryEvents>

get(eventId): Event | undefined;

Defined in: core/src/event/event.registry.ts:60

Returns the event type with the given id, or undefined if none matches.

Parameter Type
eventId string

Event | undefined


list(): Event[];

Defined in: core/src/event/event.registry.ts:55

Lists all registered event types.

Event[]


publish<TPayload, TFilter>(event, payload): void;

Defined in: core/src/event/event.registry.ts:79

Publishes a payload for the given event, notifying both id-specific and wildcard subscribers.

The payload is validated against the event’s payload schema first, and what subscribers receive is the parsed value. The schema is the event’s public contract, so this is where it is enforced: check compares the payload against a subscriber’s filter, and a payload that has drifted from its schema would otherwise silently stop matching. Validating up front also means a malformed occurrence reaches no subscriber rather than some of them.

Throws EventPayloadValidationError on a mismatch. That surfaces in whatever published — usually an action, after its effect has already happened — which is the same trade defineAction makes for its output.

Type Parameter
TPayload extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
TFilter extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Parameter Type
event Event<TPayload, TFilter>
payload output<TPayload>

void


register(...events): void;

Defined in: core/src/event/event.registry.ts:48

Registers one or more event types, replacing any existing type with the same id.

Parameter Type
events Event[]

void


subscribe<TPayload, TFilter>(
event,
listener,
options?): void;

Defined in: core/src/event/event.registry.ts:106

Subscribes to publishes of the given event. Pass an AbortSignal (or options.abortSignal) to remove the listener, and options.filter to receive only the occurrences the event’s check accepts.

The filter is validated against the event’s filter schema up front, so a filter that could never match fails here rather than by silently delivering nothing. check then receives the parsed value.

Type Parameter
TPayload extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
TFilter extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>
Parameter Type
event Event<TPayload, TFilter>
listener (payload) => void
options | AbortSignal | SubscribeOptions<TFilter>

void