UNPKG

@vegajs/event-bus

Version:

A flexible and typed Event Bus implementation for TypeScript and JavaScript projects. It facilitates communication between components and modules without tight coupling.

9 lines (8 loc) 435 B
import type { EventBus as IEventBus } from './types'; export declare class EventBus<EventMap> implements IEventBus<EventMap> { private listeners; on<K extends keyof EventMap>(eventName: K, handler: (event: EventMap[K]) => void): void; off<K extends keyof EventMap>(eventName: K, handler: (event: EventMap[K]) => void): void; emit<K extends keyof EventMap>(eventName: K, event: EventMap[K]): void; offAll(): void; }