import { EventParams } from './EventParams'; /** * Allows a decoupled and asynchronous communication between components. * Components can publish events for a given topic and * others can subscribe for future events for topics they are interested in. * * @public */ export interface EventsService { /** * Publishes an event for the topic. * * @param params - parameters for the to be published event. */ publish(params: EventParams): Promise; /** * Subscribes to one or more topics, registering an event handler for them. * * @param options - event subscription options. */ subscribe(options: EventsServiceSubscribeOptions): Promise; } /** * @public */ export type EventsServiceSubscribeOptions = { /** * Identifier for the subscription. E.g., used as part of log messages. */ id: string; topics: string[]; onEvent: EventsServiceEventHandler; }; /** * @public */ export type EventsServiceEventHandler = (params: EventParams) => Promise;