Interface WidgetEventEmitter

An interface for UI classes that can emit events, such as a Widget or a Root.

interface WidgetEventEmitter {
    off(eventType: string, listener: WidgetEventListener, once?: boolean): boolean;
    offAny(listener: WidgetEventListener): boolean;
    on(eventType: string, listener: WidgetEventListener, once?: boolean): this;
    onAny(listener: WidgetEventListener): this;
}

Implemented by

Methods

Methods

  • Remove a specific event listener for a specific type. Note that if the same listener callback is reused only the first one is removed. The once parameter must match for the listener to be removed.

    Parameters

    • eventType: string

      The event type that the listener is listening to.

    • listener: WidgetEventListener

      The listener/callback to remove.

    • Optionalonce: boolean

      Was the listener marked as a once-only event. False by default.

    Returns boolean

    Returns true if a listener was removed, false otherwise.

  • Remove a specific untyped event listener. Note that if the same listener callback is reused only the first one is removed.

    Parameters

    Returns boolean

    Returns true if a listener was removed, false otherwise.

  • Add event listener for a specific event type. Chainable.

    Parameters

    • eventType: string

      The event type to listen to. Any other event type will not invoke this listener callback.

    • listener: WidgetEventListener

      The listener/callback to invoke when the event is emitted.

    • Optionalonce: boolean

      Should the listener be removed after being invoked once? False by default.

    Returns this