class InMemoryEventBus
implements IEventBus
Since 0.1.0

In-memory publish/subscribe event bus.

Implements IEventBus. Dispatch policy (async/errorHandler) is configured at construction. Handler errors are isolated through errorHandler and never cause publish to reject.

Constructors

InMemoryEventBus(options: EventDispatchOptions)

Properties

readonly
subscriptionCount: number

Returns the count of subscribed event types (for health reporting).

Methods

clear(): void

Removes all subscriptions.

Internal method for lifecycle cleanup (NOT on IEventBus).

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>(
type: string,
handler: EventHandler<T>
): () => void

Subscribes to an event type.

whenIdle(): Promise<void>

Resolves once all in-flight fire-and-forget handlers settle.

Internal test seam (concrete-class only, NOT on IEventBus).

Usage

import { InMemoryEventBus } from "events-plugin/src/index.ts";