1 import type { InternalEventType } from './InternalEventType'
2 import type { InternalEventHandlerInterface } from './InternalEventHandlerInterface'
3 import type { InternalEventInterface } from './InternalEventInterface'
4 import type { InternalEventPublishStrategy } from './InternalEventPublishStrategy'
6 export interface InternalEventBusInterface {
8 * Associate an event handler with a certain event type
9 * @param handler event handler instance
10 * @param eventType event type to associate with
12 addEventHandler(handler: InternalEventHandlerInterface, eventType: InternalEventType): void
14 addEventCallback<Data = unknown>(callback: (data: Data) => void, eventType: string): () => void
16 removeEventHandler(handler: InternalEventHandlerInterface, eventType: string): void
19 * Asynchronously publish an event for handling
20 * @param event internal event object
22 publish<Payload = unknown>(event: InternalEventInterface<Payload>): void
24 * Synchronously publish an event for handling.
25 * This will await for all handlers to finish processing the event.
26 * @param event internal event object
27 * @param strategy strategy with which the handlers will process the event.
28 * Either all handlers will start at once or they will do it sequentially.
30 publishSync(event: InternalEventInterface, strategy: InternalEventPublishStrategy): Promise<void>