export default class EventBus { private handlers; private readonly dirtyEvents; private publishDepth; private closed; /** * Subscribe to an event */ subscribe(eventType: E, callback: (data: EventTypes[E]) => void): () => void; /** * Subscribe to an event once */ once(eventType: E, callback: (data: EventTypes[E]) => void): () => void; /** * Unsubscribe a specific callback from an event by reference * @returns true if the callback was found and removed, false otherwise */ unsubscribe(eventType: E, callback: (data: EventTypes[E]) => void): boolean; /** * Internal method to add an event handler */ private addHandler; private removeHandler; private compactEvent; private compactDirtyEvents; /** * Publish an event. Data is required unless EventTypes[E] extends void | undefined. * Snapshot length prevents handlers added mid-publish from being called in the same cycle. * Removed handlers remain as inactive tombstones until publication finishes, so removing * one handler cannot shift an unrelated handler into the current index. */ publish(eventType: EventTypes[E] extends void | undefined ? E : never): void; publish(eventType: E, data: EventTypes[E]): void; clear(): void; clearEvent(eventType: E): void; /** @internal Prevent new subscriptions and event delivery during world disposal. */ close(): void; }