Class EventEmitter

The EventEmitter class provides a way to define, emit, and handle events.

Hierarchy

Index

Methods

getListeners

  • getListeners(event: string): Function[]
  • Gets all the listeners for a specified event.

    Parameters

    • event: string

      The event name.

    Returns Function[]

off

  • off(event: string, listener: Function): void
  • Removes the listener for a specified event.

    Parameters

    • event: string

      The event name.

    • listener: Function

      The callback that corresponds to the event listener.

    Returns void

on

  • on(event: string, listener: Function): void
  • Listens for a specified event.

    When the specified event happens, the SDK triggers the callback that you pass.

    Parameters

    • event: string

      The event name.

    • listener: Function

      The callback to trigger.

    Returns void

once

  • once(event: string, listener: Function): void
  • Listens for a specified event once.

    When the specified event happens, the SDK triggers the callback that you pass and then removes the listener.

    Parameters

    • event: string

      The event name.

    • listener: Function

      The callback to trigger.

    Returns void

removeAllListeners

  • removeAllListeners(event?: string): void
  • Removes all listeners for a specified event.

    Parameters

    • Optional event: string

      The event name. If left empty, all listeners for all events are removed.

    Returns void