Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventEmitter<Events>

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

Static prefixed

prefixed: string | boolean

Methods

addListener

emit

  • emit<K>(event: K, ...args: Events[K]): boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

listenerCount

  • listenerCount(event: string | symbol): number
  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

listeners

  • Return the listeners registered for a given event.

    Parameters

    • event: string | symbol

    Returns ListenerFn[]

off

  • Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns EventEmitter<Events>

on

  • on<K>(event: K, fn: (...params: Events[K]) => void, context?: any): EventEmitter<Events>
  • Add a listener for a given event.

    Type parameters

    • K: string

    Parameters

    • event: K
    • fn: (...params: Events[K]) => void
        • (...params: Events[K]): void
        • Parameters

          • Rest ...params: Events[K]

          Returns void

    • Optional context: any

    Returns EventEmitter<Events>

once

  • once<K>(event: K, fn: (...params: Events[K]) => void, context?: any): EventEmitter<Events>
  • Add a one-time listener for a given event.

    Type parameters

    • K: string

    Parameters

    • event: K
    • fn: (...params: Events[K]) => void
        • (...params: Events[K]): void
        • Parameters

          • Rest ...params: Events[K]

          Returns void

    • Optional context: any

    Returns EventEmitter<Events>

removeAllListeners

  • removeAllListeners(event?: string | symbol): EventEmitter<Events>
  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns EventEmitter<Events>

removeListener

  • removeListener(event: string | symbol, fn?: ListenerFn, context?: any, once?: boolean): EventEmitter<Events>
  • Remove the listeners of a given event.

    Parameters

    • event: string | symbol
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns EventEmitter<Events>

Generated using TypeDoc