Back to reference

EventEmitter

Emits events much like Node's EventEmitteropen in new window.

editor.addEventListener("openOAuthUrl", (event) => {
  const url = event.detail;
  // ...
});

The variable editor is an instance of Editor which implements EventEmitter interface.

declare class EventEmitter<T> implements Disposable {
  addEventListener<E extends string & keyof T>(event: E, listener: EventListener<T[E]>): void;
  removeEventListener<E extends string & keyof T>(event: E, listener: EventListener<T[E]>): void;
}

Methods

addEventListener()

Register a function to be called whenever a specified event is emitted.

addEventListener<E extends string & keyof T>(event: E, listener: EventListener<T[E]>): void;

Parameters

NameTypeDescription
eventE
listenerEventListener<T[E]>

removeEventListener()

Remove a previously added listener function.

removeEventListener<E extends string & keyof T>(event: E, listener: EventListener<T[E]>): void;

Parameters

NameTypeDescription
eventE
listenerEventListener<T[E]>
Last Updated: 4/22/2022, 6:49:35 PM