Class EventDispatcher<E>

JavaScript events for custom objects

Source

src/core/EventDispatcher.js

Type Parameters

Hierarchy

Constructors

  • Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object.

    Type Parameters

    Returns EventDispatcher<E>

Methods

  • Adds a listener to an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<E, T, EventDispatcher<E>>

      The function that gets called when the event is fired.

    Returns void

  • Fire an event type.

    Parameters

    • event: E

    Returns void

  • Checks if listener is added to an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<E, T, EventDispatcher<E>>

      The function that gets called when the event is fired.

    Returns boolean

  • Removes a listener from an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: EventListener<E, T, EventDispatcher<E>>

      The listener function that gets removed.

    Returns void

Generated using TypeDoc