Interface IEventDispatcher<T>

A simple event dispatcher interface with IEvent as event type.

interface IEventDispatcher<T> {
    addEventListener(type, listener): void;
    dispatchEvent(event): void;
    hasEventListener(type, listener): boolean;
    removeEventListener(type, listener): void;
}

Type Parameters

  • T

Implemented by

Methods

  • Adds a listener to an event type.

    Parameters

    • type: T

      The type of event to listen to.

    • listener: ((event) => void)

      The function that gets called when the event is fired.

        • (event): void
        • Parameters

          Returns void

    Returns void

  • Fire an event type.

    Parameters

    Returns void

  • Checks if listener is added to an event type.

    Parameters

    • type: T

      The type of event to listen to.

    • listener: ((event) => void)

      The function that gets called when the event is fired.

        • (event): void
        • Parameters

          Returns void

    Returns boolean

  • Removes a listener from an event type.

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: ((event) => void)

      The listener function that gets removed.

        • (event): void
        • Parameters

          Returns void

    Returns void