Phials developer documentation
User guide
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

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}.