AI Notice: Most documentation right now was auto-generated by an LLM. Handwritten documentation will be implemented over time on the road to 1.0
EventsAPI
Events API for pub/sub cross-plugin communication
Signature
interface EventsAPI {
on<K extends keyof EventMap>(eventId: K, handler: EventHandler<EventMap[K]>): EventSubscription;
once<K extends keyof EventMap>(eventId: K, handler: EventHandler<EventMap[K]>): EventSubscription;
emit<K extends keyof EventMap>(eventId: K, payload: EventMap[K]): void;
register(localId: string, description?: string): void;
}Members
| Name | Type | Required | Description |
|---|---|---|---|
on | (eventId: K, handler: EventHandler<EventMap[K]>) => EventSubscription | yes | Subscribe to an event. |
once | (eventId: K, handler: EventHandler<EventMap[K]>) => EventSubscription | yes | Subscribe to an event once (auto-unsubscribes after first trigger). |
emit | (eventId: K, payload: EventMap[K]) => void | yes | Emit an event to all subscribers. |
register | (localId: string, description?: string) => void | yes | Register a new event type (namespaced to plugin). The full event ID will be {pluginId}`.`{localId}. |