/** * Simple Event Emitter * * Lightweight pub/sub system for internal feature communication. * Following PostHog's SimpleEventEmitter pattern. */ /** * Event listener function type */ export type EventListener = (payload: T) => void; /** * Unsubscribe function returned by on() */ export type Unsubscribe = () => void; /** * Simple event emitter for internal SDK communication. * Features can emit and listen to events without direct coupling. * * @example * ```typescript * const emitter = new SimpleEventEmitter(); * * // Subscribe to events * const unsubscribe = emitter.on('user:identified', (data) => { * console.log('User identified:', data); * }); * * // Emit events * emitter.emit('user:identified', { userId: '123' }); * * // Unsubscribe when done * unsubscribe(); * ``` */ export declare class SimpleEventEmitter { private _events; private _onceEvents; /** * Subscribe to an event. * * @param event - Event name to subscribe to * @param listener - Callback function * @returns Unsubscribe function */ on(event: string, listener: EventListener): Unsubscribe; /** * Subscribe to an event once (auto-unsubscribes after first call). * * @param event - Event name to subscribe to * @param listener - Callback function * @returns Unsubscribe function */ once(event: string, listener: EventListener): Unsubscribe; /** * Emit an event to all listeners. * * @param event - Event name to emit * @param payload - Data to pass to listeners */ emit(event: string, payload?: T): void; /** * Remove all listeners for an event. * * @param event - Event name (or undefined to remove all) */ off(event?: string): void; /** * Get the number of listeners for an event. * * @param event - Event name * @returns Number of listeners */ listenerCount(event: string): number; /** * Check if there are any listeners for an event. * * @param event - Event name * @returns True if there are listeners */ hasListeners(event: string): boolean; } /** * VTilt SDK Events * * Standard events emitted by the SDK for internal communication. */ export declare const VTiltEvents: { readonly INITIALIZED: "sdk:initialized"; readonly CONFIG_UPDATED: "sdk:config_updated"; readonly REMOTE_CONFIG_LOADED: "sdk:remote_config_loaded"; readonly USER_IDENTIFIED: "user:identified"; readonly USER_RESET: "user:reset"; readonly USER_PROPERTIES_SET: "user:properties_set"; readonly SESSION_STARTED: "session:started"; readonly SESSION_ENDED: "session:ended"; readonly SESSION_ROTATED: "session:rotated"; readonly FEATURE_STARTED: "feature:started"; readonly FEATURE_STOPPED: "feature:stopped"; readonly CONSENT_UPDATED: "consent:updated"; readonly EVENT_CAPTURED: "event:captured"; readonly EVENT_SENT: "event:sent"; readonly EVENT_FAILED: "event:failed"; readonly RECORDING_STARTED: "recording:started"; readonly RECORDING_STOPPED: "recording:stopped"; readonly ERROR: "error"; }; export type VTiltEventName = (typeof VTiltEvents)[keyof typeof VTiltEvents];