export type EventType = string; export type EventListener = (event: Event) => Promise; /** * Event is a generic event originating from a tendril app (not the PVM). */ export interface Event { /** * type distinguishes the event. */ type: EventType; } export declare class InitEvent { type: string; } export declare class ConnectedEvent { type: string; } export declare class StartedEvent { type: string; } /** * EventDispatcher is a simple event dispatcher for tendril applications. */ export declare class EventDispatcher { listeners: Map>; constructor(listeners?: Map>); /** * addListener adds a listener for a specific event type. * * A listener can only be added once for a specific event type. */ addListener(type: EventType, listener: EventListener): void; /** * removeListener removes a single listener for a specific event type. */ removeListener(type: EventType, listener: EventListener): void; /** * removeListeners removes all listeners for a specific event type. */ removeListeners(type: EventType): void; /** * dispatch an event to all listeners. */ dispatch(event: Event): Promise; }