Skip to main content

EventDispatcher <T>

@deprecated

Use [[EventEmitter]] will be removed in v0.29.0

Implements

Index

Constructors

constructor

Methods

publicclear

  • clear(): void
  • Clears any existing handlers or wired event dispatchers on this event dispatcher


    Returns void

publicemit

  • emit(eventName: string, event: GameEvent<T, T>): void
  • Emits an event for target


    Parameters

    • eventName: string

      The name of the event to publish

    • event: GameEvent<T, T>

      Optionally pass an event data object to the handler

    Returns void

publicoff

  • off(eventName: string, handler?: (event: GameEvent<T, T>) => void): void
  • Unsubscribe an event handler(s) from an event. If a specific handler is specified for an event, only that handler will be unsubscribed. Otherwise all handlers will be unsubscribed for that event.


    Parameters

    • eventName: string

      The name of the event to unsubscribe

    • optionalhandler: (event: GameEvent<T, T>) => void

      Optionally the specific handler to unsubscribe

    Returns void

publicon

  • on(eventName: string, handler: (event: GameEvent<T, T>) => void): void
  • Subscribe an event handler to a particular event name, multiple handlers per event name are allowed.


    Parameters

    • eventName: string

      The name of the event to subscribe to

    • handler: (event: GameEvent<T, T>) => void

      The handler callback to fire on this event

    Returns void

publiconce

  • once(eventName: string, handler: (event: GameEvent<T, T>) => void): void
  • Once listens to an event one time, then unsubscribes from that event


    Parameters

    • eventName: string

      The name of the event to subscribe to once

    • handler: (event: GameEvent<T, T>) => void

      The handler of the event that will be auto unsubscribed

    Returns void

publicunwire

  • Unwires this event dispatcher from another


    Parameters

    Returns void

publicwire

  • Wires this event dispatcher to also receive events from another


    Parameters

    Returns void