type EventHandler = (data: T) => void; /** * A simple event emitter implementation that provides type-safe event handling. * Supports subscribing to events, unsubscribing, and emitting events with payloads. * Events are handled synchronously and any errors in handlers are caught and logged. */ export declare class EventEmitter { /** Map of event names to their set of handlers */ private handlers; /** * Subscribes to an event. * @param event - The name of the event to listen for * @param handler - The callback function to execute when the event occurs * @returns A function that can be called to unsubscribe from the event * * @example * ```typescript * const unsubscribe = emitter.on('userUpdate', (data: UserData) => { * console.log('User updated:', data); * }); * * // Later, to stop listening: * unsubscribe(); * ``` */ on(event: string, handler: EventHandler): () => void; /** * Unsubscribes a handler from an event. * If this was the last handler for the event, the event is removed from the handlers map. * @param event - The name of the event to unsubscribe from * @param handler - The handler function to remove */ off(event: string, handler: EventHandler): void; /** * Emits an event with the provided data. In addition to calling handlers for the specific event, * it also calls any wildcard ('*') handlers. Wildcard handlers receive an object with { event, payload }. */ emit(event: string, data: T): void; /** * Removes all event handlers. * After calling this method, no events will be handled until new handlers are registered. */ clear(): void; /** * Checks if an event has any active listeners. * @param event - The name of the event to check * @returns True if the event has at least one handler, false otherwise */ hasListeners(event: string): boolean; } export {}; //# sourceMappingURL=event-emitter.d.ts.map