Class Emitter<EventNames>

Emitter class that powers the subscribe packet

Type Parameters

  • EventNames = string

Hierarchy

  • Emitter

Constructors

Properties

Methods

Constructors

  • Use the constructor to initiate the eventbus with handlers

    Type Parameters

    • EventNames = string

    Parameters

    • listeners: EventHandlerMap = {}

    Returns Emitter<EventNames>

Properties

listeners: EventHandlerMap = {}

Methods

  • Invoke this.listeners handlers for the given type. If present, "*" handlers are invoked after type-matched handlers.

    Note: Manually firing "*" handlers is not supported.

    Parameters

    • type: string & EventNames

      The event type to invoke

    • Optional evt: any

      Any value (object is recommended and powerful), passed to each handler

    Returns void

  • Remove an event handler for the given type.

    Parameters

    • type: string & EventNames

      Type of event to unregister handler from, or "*"

    • Optional handler: EventHandler | WildCardEventHandler

      Handler function to remove

    Returns void

  • Register an event handler for the given type.

    Parameters

    • type: "*" | string & EventNames

      Type of event to listen for, or "*" for all events

    • handler: EventHandler | WildCardEventHandler

      Function to call in response to given event

    Returns void

  • Invoke this listener only once

    Parameters

    • type: string & EventNames

      Type of event to emit, or "*" for all events

    • handler: EventHandler

    Returns void

Generated using TypeDoc