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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EventRegistry(): EventRegistry;Defined in: core/src/event/event.registry.ts:37
Returns
Section titled “Returns”EventRegistry
Accessors
Section titled “Accessors”emitter
Section titled “emitter”Get Signature
Section titled “Get Signature”get emitter(): EventEmitter<EventRegistryEvents>;Defined in: core/src/event/event.registry.ts:43
The underlying emitter, exposed for wiring event forwarding.
Returns
Section titled “Returns”EventEmitter<EventRegistryEvents>
Methods
Section titled “Methods”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
eventId |
string |
Returns
Section titled “Returns”Event | undefined
list()
Section titled “list()”list(): Event[];Defined in: core/src/event/event.registry.ts:55
Lists all registered event types.
Returns
Section titled “Returns”Event[]
publish()
Section titled “publish()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
TPayload extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
TFilter extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
Event<TPayload, TFilter> |
payload |
output<TPayload> |
Returns
Section titled “Returns”void
register()
Section titled “register()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
…events |
Event[] |
Returns
Section titled “Returns”void
subscribe()
Section titled “subscribe()”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 Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
TPayload extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
TFilter extends ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>> |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
Event<TPayload, TFilter> |
listener |
(payload) => void |
options |
| AbortSignal | SubscribeOptions<TFilter> |
Returns
Section titled “Returns”void