UNPKG

@eolme/vma-engine

Version:
16 lines (15 loc) 790 B
export declare type EventType = string | symbol | '*'; export declare type Handler<T = any> = (event: T | null, type: EventType) => void; export declare type EventHandlerList = Set<Handler>; export declare type EventHandlerMap = Map<EventType, EventHandlerList>; export declare type EventOnceHandlerMap = Map<Handler, Handler>; export declare interface Emitter { on<T = any>(type: EventType, handler: Handler<T>): void; once<T = any>(type: EventType, handler: Handler<T>): void; off<T = any>(type: EventType, handler: Handler<T>): void; emit<T = any>(type: EventType, event?: T): void; clear(): void; } declare const createBus: () => Emitter; declare const readonlyBus: Readonly<Emitter>; export { createBus, readonlyBus as bus, readonlyBus as default };