Abstract base class for domain events.
-
data: T
The event payload.
-
id: string
Unique event ID.
-
occurredOn: Date
When the event occurred.
-
type: string
Event type name (e.g.
"UserCreated").
In-memory publish/subscribe event bus.
-
clear(): void
Removes all subscriptions.
-
publish<T>(event: IDomainEvent<T>): Promise<void>
Publishes an event to every subscriber of its type.
-
publishBatch(events: IDomainEvent[]): Promise<void>
Publishes multiple events, each to its own subscribers.
-
subscribe<T>(): () => voidtype: string,handler: EventHandler<T>
Subscribes to an event type.
-
subscriptionCount(): number
Returns the count of subscribed event types (for health reporting).
-
whenIdle(): Promise<void>
Resolves once all in-flight fire-and-forget handlers settle.
Abstract base class for integration (cross-service) events.
Creates an aggregate-local domain event recorder.
Runtime-bound abstract bases for ergonomic construction.
Creates the EventsPlugin.
Adapts a class-based handler to the EventHandler function signature and
subscribes it to the bus. Returns the Unsubscribe function.
One event handler and the event type it subscribes to.
-
handler: IEventHandler<unknown>
| RegistryFactory<IEventHandler<unknown>>The handler to subscribe for that type, or a factory that builds one from the service registry.
-
type: string
Event type name, matching
event.type.
Options for the EventsPlugin.
-
async: boolean
Dispatch policy for event handlers.
-
errorHandler: () => voiderror: unknown,event: IDomainEvent
Handler for errors thrown/rejected by event handlers.
-
handlers: readonly EventHandlerRegistration[]
Handlers subscribed to the bus at
register()time.
A domain event.
-
aggregateId: string
ID of the aggregate that produced the event, when applicable.
-
data: T
The event payload.
-
id: string
Unique event ID.
-
occurredOn: Date
When the event occurred.
-
type: string
Event type name (e.g.
"UserCreated"). -
version: number
Aggregate version, for event-sourced aggregates.
Records domain facts raised by one aggregate during its current operation.
-
clear(): void
Removes all pending facts.
-
pending(): readonly IDomainEvent[]
Returns an ordered, read-only snapshot of pending facts.
-
record<T>(event: IDomainEvent<T>): void
Appends an event reference to the pending facts in insertion order.
-
remove(event: IDomainEvent): boolean
Removes the first pending reference that is strictly equal to
event.
In-memory publish/subscribe event bus for domain events.
-
publish<T>(event: IDomainEvent<T>): Promise<void>
Publishes an event to every subscriber of its type.
-
publishBatch(events: IDomainEvent[]): Promise<void>
Publishes multiple events, each to its own subscribers.
-
subscribe<T>(): Unsubscribetype: string,handler: EventHandler<T>
Subscribes to an event type.
Class-based event handler interface.
Handles one event type.
Removes a subscription when called.
Usage
import * as In_memory_event_bus_plugin_for_domain_events___Package_stub_created_in_Milestone_0__The_implementation_follows_in_this_package_s_milestone___see_ROADMAP_md_ from "events-plugin/src/index.ts";