Class EventDispatcher<T>

Intentionally very simple event emitter.

Type Parameters

  • T extends Record<keyof T, unknown[]>

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • Stops listening to an event.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • event: K

      the event to stop listening to.

    • listener: ((this: undefined, ...args: T[K]) => void)

      the function to remove from the listener array.

        • (this, ...args): void
        • Parameters

          • this: undefined
          • Rest...args: T[K]

          Returns void

    Returns void

  • Starts listening to an event.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • event: K

      the event to listen to.

    • listener: ((this: undefined, ...args: T[K]) => void)

      function to be called when an this event is emitted.

        • (this, ...args): void
        • Parameters

          • this: undefined
          • Rest...args: T[K]

          Returns void

    • priority: number = 0

      optional priority to insert this hook with.

    Returns void

  • Emits an event to all currently subscribed listeners.

    Type Parameters

    • K extends string | number | symbol

    Parameters

    • event: K

      the event to emit.

    • Rest...args: T[K]

      any arguments required for the event.

    Returns void