Type Parameters

  • EventData

Constructors

Properties

defaultMaxListeners: number

Methods

  • Adds a listener to the end of the listeners array for the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    Returns any

  • Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns boolean

  • Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns Promise<any[]>

  • Returns an array listing the events for which the emitter has registered listeners.

    Note: Listeners order not guaranteed

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • OptionalnsAsArray: boolean

    Returns Name[]

  • Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter2.defaultMaxListeners

    Returns number

  • Checks whether emitter has any listeners.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns boolean

  • Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns number

  • Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns ListenerFn[]

  • Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.

    Returns ListenerFn[]

  • Parameters

    • target: GeneralEventEmitter
    • events: any
    • Optionaloptions: ListenToOptions

    Returns this

  • Parameters

    • target: GeneralEventEmitter
    • events: event[]
    • Optionaloptions: ListenToOptions

    Returns this

  • Parameters

    • target: GeneralEventEmitter
    • events: object
    • Optionaloptions: ListenToOptions

    Returns this

  • Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first n times the event is fired, after which it is removed.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • timesToListen: number
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first n times the event is fired, after which it is removed.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • timesToListen: number
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: boolean | OnOptions

    Returns this

  • Remove a listener from the listener array for the specified event. Caution: Calling this method changes the array indices in the listener array behind the listener.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    Returns this

  • Removes the listener that will be fired when any event is emitted.'

    Parameters

    • listener: ListenerFn

    Returns this

  • Adds a listener to the end of the listeners array for the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a listener to the end of the listeners array for the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: boolean | OnOptions

    Returns this

  • Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.

    Parameters

    • listener: EventAndListener

    Returns this

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: true | OnOptions

    Returns this

  • Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array

    Parameters

    • listener: EventAndListener

    Returns this

  • Adds a listener to the beginning of the listeners array for the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a listener to the beginning of the listeners array for the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: boolean | OnOptions

    Returns this

  • Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first n times the event is fired, after which it is removed. The listener is added to the beginning of the listeners array.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • timesToListen: number
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first n times the event is fired, after which it is removed. The listener is added to the beginning of the listeners array.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • timesToListen: number
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: boolean | OnOptions

    Returns this

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. The listener is added to the beginning of the listeners array

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • options: OnOptions & {
          objectify: true;
      }

    Returns Listener

  • Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. The listener is added to the beginning of the listeners array

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    • Optionaloptions: boolean | OnOptions

    Returns this

  • Removes all listeners, or those of the specified event.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    Returns this

  • Remove a listener from the listener array for the specified event. Caution: Calling this method changes the array indices in the listener array behind the listener.

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • listener: ((...args: ListenerType<EventData[Name]>) => void)
        • (...args): void
        • Parameters

          Returns void

    Returns this

  • By default EventEmitters will print a warning if more than 10 listeners are added to it. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that to be increased. Set to zero for unlimited.

    Parameters

    • n: number

    Returns void

  • Parameters

    • Optionaltarget: GeneralEventEmitter
    • Optionalevent: any

    Returns boolean

  • Returns a thenable object (promise interface) that resolves when a specific event occurs

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • Optionaltimeout: number

    Returns CancelablePromise<ListenerType<EventData[Name]>>

  • Returns a thenable object (promise interface) that resolves when a specific event occurs

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • Optionalfilter: WaitForFilter

    Returns CancelablePromise<ListenerType<EventData[Name]>>

  • Returns a thenable object (promise interface) that resolves when a specific event occurs

    Type Parameters

    • Name extends string | number | symbol

    Parameters

    • event: Name
    • Optionaloptions: WaitForOptions

    Returns CancelablePromise<ListenerType<EventData[Name]>>

  • Parameters

    • emitter: EventEmitter2
    • event: string
    • Optionaloptions: OnceOptions

    Returns CancelablePromise<any[]>