Class EventEmitter<CallbackType, ResultType, EventType>

A generic interface for event registration and delivery used in a number of the types in the Realtime client library. For example, the ConnectionBase object emits events for connection state using the EventEmitter pattern.

Type Parameters

  • CallbackType

  • ResultType

  • EventType

Hierarchy

Constructors

Methods

Constructors

  • Type Parameters

    • CallbackType

    • ResultType

    • EventType

    Returns EventEmitter<CallbackType, ResultType, EventType>

Methods

  • Returns the listeners for a specified EventType.

    Parameters

    • Optional eventName: EventType

      The event name to retrieve the listeners for.

    Returns null | CallbackType[]

  • Removes all registrations that match both the specified listener and the specified event.

    Parameters

    • event: EventType

      The named event.

    • callback: CallbackType

      The event listener.

    Returns void

  • Deregisters the specified listener. Removes all registrations matching the given listener, regardless of whether they are associated with an event or not.

    Parameters

    • callback: CallbackType

      The event listener.

    Returns void

  • Deregisters all registrations, for all events and listeners.

    Returns void

  • Registers the provided listener for the specified event. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    • event: EventType

      The named event to listen for.

    • callback: CallbackType

      The event listener.

    Returns void

  • Registers the provided listener for the specified events. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    • events: EventType[]

      The named events to listen for.

    • callback: CallbackType

      The event listener.

    Returns void

  • Registers the provided listener all events. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    • callback: CallbackType

      The event listener.

    Returns void

  • Registers the provided listener for the first occurrence of a single named event specified as the Event argument. If once is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once, and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once ensures that each registration is only invoked once.

    Parameters

    • event: EventType

      The named event to listen for.

    • callback: CallbackType

      The event listener.

    Returns void

  • Registers the provided listener for the first event that is emitted. If once() is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once(), and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once() ensures that each registration is only invoked once.

    Parameters

    • callback: CallbackType

      The event listener.

    Returns void

  • Returns a promise which resolves upon the first occurrence of a single named event specified as the Event argument.

    Returns

    A promise which resolves upon the first occurrence of the named event.

    Parameters

    • event: EventType

      The named event to listen for.

    Returns Promise<ResultType>

  • Returns a promise which resolves upon the first occurrence of an event.

    Returns

    A promise which resolves upon the first occurrence of an event.

    Returns Promise<ResultType>

Generated using TypeDoc