export type Listener = (payload: T) => void; export type Listen = (listener: Listener) => VoidFunction; export type Emit = (..._: void extends T ? [payload?: T] : [payload: T]) => void; export declare class EventBusCore extends Set> { emit(..._: void extends T ? [payload?: T] : [payload: T]): void; } export interface EventBus { readonly listen: Listen; readonly emit: Emit; readonly clear: VoidFunction; } /** * Provides a simple way to listen to and emit events. All listeners are automatically unsubscribed on cleanup. * * @returns the emitter: `{listen, emit, clear}` * * @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/event-bus#createEventBus * * @example const bus = createEventBus(); // bus can be destructured: const { listen, emit, clear } = bus; const unsub = bus.listen((a) => console.log(a)); bus.emit("foo"); // unsub gets called automatically on cleanup unsub(); */ export declare function createEventBus(): EventBus;