/**
* LadrillosJS Global Event Bus
*
* Provides cross-component communication without prop drilling.
*
* Usage:
* - $emit("event-name", data) - Emit an event to all listeners
* - $listen("event-name", callback) - Listen for events from any component
*
* @example
* ```html
*
*
*
*
*
* ```
*/
/**
* Event listener callback function type
*/
export type EventListener = (data: T) => void;
/**
* Public alias for EventListener (for external API)
*/
export type EventCallback = EventListener;
/**
* Unsubscribe function returned by $listen
*/
export type Unsubscribe = () => void;
/**
* Emit an event to all registered listeners.
*
* @param eventName - The name of the event to emit
* @param data - Optional data to pass to listeners
*
* @example
* ```js
* $emit("user-logged-in", { userId: 123, username: "john" });
* $emit("show-modal");
* $emit("item-added", { id: 1, name: "Product" });
* ```
*/
export declare function $emit(eventName: string, data?: T): void;
/**
* Listen for events from any component.
*
* @param eventName - The name of the event to listen for
* @param callback - Function to call when the event is emitted
* @param componentId - Optional component ID for automatic cleanup
* @returns Unsubscribe function to remove the listener
*
* @example
* ```js
* // Basic usage
* $listen("user-logged-in", (user) => {
* console.log(`Welcome, ${user.username}!`);
* isLoggedIn = true;
* });
*
* // With unsubscribe
* const unsubscribe = $listen("notifications", handleNotification);
* // Later: unsubscribe();
* ```
*/
export declare function $listen(eventName: string, callback: EventListener, componentId?: string): Unsubscribe;
/**
* Remove all listeners registered by a specific component.
* Called automatically when a component is disconnected from the DOM.
*
* @param componentId - The component's unique ID
*/
export declare function cleanupComponentListeners(componentId: string): void;
/**
* Remove all event listeners (useful for testing)
*/
export declare function clearAllListeners(): void;
/**
* Get the count of listeners for an event (useful for debugging)
*/
export declare function getListenerCount(eventName: string): number;
/**
* Check if an event has any listeners
*/
export declare function hasListeners(eventName: string): boolean;
/**
* Creates event bus helpers bound to a specific component.
* This enables automatic cleanup when the component is disconnected.
*
* @param componentId - The unique ID of the component
* @returns Object containing bound $emit and $listen functions
*/
export declare function createEventBusHelpers(componentId: string): {
$emit: (eventName: string, data?: T) => void;
$listen: (eventName: string, callback: EventListener) => Unsubscribe;
};
/**
* Names of event bus helpers (for Function parameter lists)
*/
export declare const eventBusHelperNames: string[];