/** Represents a subscription that can be cancelled */ export interface Subscription { /** Cancels the subscription and removes the listener */ unsubscribe(): void; } /** * Generic event emitter for pub/sub pattern with type-safe events * @template T The event payload type (defaults to void for events without data) */ export declare class EventEmitter { #private; /** * Subscribes a listener to events * @param listener Function to call when events are emitted * @returns Subscription object to cancel the listener */ subscribe(listener: (event: T) => void): Subscription; /** * Emits an event to all subscribed listeners * @param event The event payload to send to listeners */ emit(event: T): void; /** Removes all listeners */ clear(): void; /** Returns the current number of active listeners */ get listenerCount(): number; } /** * Manages multiple subscriptions as a single unit for batch cleanup * Useful for managing event listeners that should all be cleaned up together */ export declare class SubscriptionManager implements Subscription { #private; /** * Adds one or more subscriptions to manage * @param subscriptions Subscriptions to add to the manager */ add(...subscriptions: Subscription[]): void; /** Unsubscribes from all managed subscriptions */ unsubscribe(): void; /** Returns whether all subscriptions have been unsubscribed */ get isUnsubscribed(): boolean; }