import type { AnyFunc } from "../utils/basic.js"; export type EventBusListener = (event: T, payload?: P) => void; export type EventBusEvents = Set>; export type EventBusIdentifier = symbol | string | number; export interface UseEventBusReturns { /** * Subscribe to an event. When calling emit, the listeners will execute. * * @param listener watch listener. * @returns a stop function to remove the current callback. */ on: (listener: EventBusListener) => AnyFunc; /** * Similar to `on`, but only fires once * * @param listener watch listener. * @returns a stop function to remove the current callback. */ once: (listener: EventBusListener) => AnyFunc; /** * Emit an event, the corresponding event listeners will execute. * * @param event data sent. */ emit: (event?: T, payload?: P) => void; /** * Remove the corresponding listener. * * @param listener watch listener. */ off: (listener: EventBusListener) => void; /** * Clear all events in global scope */ reset(): void; /** * Clear all listeners in the current component context */ cleanup(): void; } export interface UseEventBusOptions { /** * Whether to automatically clean up the listener when the component is unmounted. * * @defaultValue true */ autoCleanup?: boolean; } export declare const events: Map>; /** * A React Hook that provides a simple event bus for your application. * * TODO: add a hooks to consume event (auto release when unmount) */ export declare function useEventBus(key: EventBusIdentifier, options?: UseEventBusOptions): UseEventBusReturns;