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]&gt

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]&gt
Last Updated: 10/12/2022, 8:08:40 PM