@empoleon/solid-bus
Version:
A global event emitter for solid.
17 lines (16 loc) • 647 B
TypeScript
import { type ParentComponent } from "solid-js";
import { type Emitter, type EventType, type Handler } from "mitt";
type Events = Record<EventType, unknown>;
/** Return the event emitter. */
export declare function useBus(): Emitter<Events>;
/**
* Attach an event listener to the bus while this component is mounted.
*
* Adds the listener after mount, and removes it before unmount.
*/
export declare function useListener(name: EventType, listener: Handler): void;
/**
* Create an event emitter that will be available to all deeply nested child elements using the useBus() hook.
*/
export declare const Provider: ParentComponent;
export {};