Class EventDispatcher<T>

Intentionally very simple event emitter.

Type Parameters

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

Hierarchy (View Summary)

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.

    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.

    • 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.

    • ...args: T[K]

      any arguments required for the event.

    Returns void