Phials plugin documentation
User guide
AI Disclosure: This page was generated by an LLM and may contain inaccuracies. Hand-crafted documentation will be implemented over time on the road to 1.0

EventsAPI

Since Plugin API: 1.0.0

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

NameTypeRequiredDescription
on(eventId: K, handler:EventHandler<EventMap[K]>) =>EventSubscriptionyesSubscribe to an event.
once(eventId: K, handler:EventHandler<EventMap[K]>) =>EventSubscriptionyesSubscribe to an event once (auto-unsubscribes after first trigger).
emit(eventId: K, payload:EventMap[K]) => voidyesEmit an event to all subscribers.
register(localId: string, description?: string) => voidyesRegister a new event type (namespaced to plugin). The full event ID will be {pluginId}`.`{localId}.