Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventEmitter<EventTypes>

Minimal EventEmitter interface that is molded against the Node.js EventEmitter interface.

Type parameters

  • EventTypes: string | symbol = string | symbol

Hierarchy

Index

Constructors

constructor

  • Type parameters

    • EventTypes: string | symbol = string | symbol

    Returns EventEmitter<EventTypes>

Properties

Static prefixed

prefixed: string | boolean

Methods

addListener

  • Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns EventEmitter<EventTypes>

emit

  • emit(event: EventTypes, ...args: any[]): boolean
  • Calls each of the listeners registered for a given event.

    Parameters

    • event: EventTypes
    • Rest ...args: any[]

    Returns boolean

eventNames

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

    Returns EventTypes[]

listenerCount

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

    Parameters

    • event: EventTypes

    Returns number

listeners

  • Return the listeners registered for a given event.

    Parameters

    • event: EventTypes

    Returns ListenerFn[]

off

  • Parameters

    • event: EventTypes
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns EventEmitter<EventTypes>

on

  • Add a listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns EventEmitter<EventTypes>

once

  • Add a one-time listener for a given event.

    Parameters

    • event: EventTypes
    • fn: ListenerFn
    • Optional context: any

    Returns EventEmitter<EventTypes>

removeAllListeners

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

    Parameters

    • Optional event: EventTypes

    Returns EventEmitter<EventTypes>

removeListener

  • Remove the listeners of a given event.

    Parameters

    • event: EventTypes
    • Optional fn: ListenerFn
    • Optional context: any
    • Optional once: boolean

    Returns EventEmitter<EventTypes>

Generated using TypeDoc