/** * Service for handling application level events */ export interface EventDispatcher { /** * Dispatch a new event * * @param {string} eventName name of the event to dispatch * @param {T} data data attached to the event */ dispatch(eventName: string, data: T): CustomEvent; /** * Add a new listener for a specific event * * @param {string} eventName name of the event to listen to * @param {Function} listener listener to invoke when the event is dispatched */ addListener(eventName: string, listener: (event: CustomEvent) => void): void; /** * Stop listening for a specific event * * @param {string} eventName name of the event to stop listening to * @param {Function} listener listener to remove from the dispatcher */ removeListener(eventName: string, listener: (event: CustomEvent) => void): void; }