22 lines
598 B
TypeScript
22 lines
598 B
TypeScript
import type { EventBusEvent } from './event-bus-event';
|
|
|
|
export const eventBus: EventTarget = {
|
|
addEventListener(
|
|
type: EventType,
|
|
listener: EventListenerOrEventListenerObject,
|
|
options?: AddEventListenerOptions,
|
|
): void {
|
|
window.addEventListener(type, listener, options);
|
|
},
|
|
dispatchEvent(event: EventBusEvent): boolean {
|
|
return window.dispatchEvent(event);
|
|
},
|
|
removeEventListener(
|
|
type: EventType,
|
|
callback: EventListenerOrEventListenerObject,
|
|
options?: EventListenerOptions,
|
|
): void {
|
|
window.removeEventListener(type, callback, options);
|
|
},
|
|
};
|