Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventEmitter<TEvents>

Type parameters

Hierarchy

  • EventEmitter

Index

Constructors

Properties

listeners: TEvents = ...

The Listeners that always run.

listenersOnce: TEvents = ...

The Listeners that only runs once.

instance?: any

The singleton.

Methods

  • emit<P>(event: P, ...args: Parameters<TEvents[P][number]>): Promise<EventEmitter<TEvents>>
  • Fire the event.

    Type parameters

    • P: string | number | symbol

    Parameters

    • event: P

      The event name.

    • Rest ...args: Parameters<TEvents[P][number]>

      The arguments to pass to the listeners.

    Returns Promise<EventEmitter<TEvents>>

  • eventNames(): (string | keyof TEvents)[]
  • has(event?: string, listener?: CallableFunction): boolean
  • Determine whether listeners exists.

    Parameters

    • Optional event: string

      only check for listeners for the given event

    • Optional listener: CallableFunction

      only check for listeners that match this given listener

    Returns boolean

  • listenerCount(event?: keyof TEvents): number
  • Get the number of listeners registered.

    Parameters

    • Optional event: keyof TEvents

      only count the listeners for the given event

    Returns number

  • off(event?: string, listener?: CallableFunction): EventEmitter<TEvents>
  • Remove the the listeners.

    Parameters

    • Optional event: string

      only remove listeners for the given event

    • Optional listener: CallableFunction

      only remove the event listener that match the given listener.

    Returns EventEmitter<TEvents>

  • on<P>(event: P, listener: Listener<Parameters<TEvents[P][number]>[number]>): EventEmitter<TEvents>
  • on(event: string, listener: CallableFunction): EventEmitter<TEvents>
  • once<P>(event: P, listener: Listener<Parameters<TEvents[P][number]>[number]>): EventEmitter<TEvents>
  • once(event: string, listener: CallableFunction): EventEmitter<TEvents>
  • prependListener<P>(event: P, listener: Listener<Parameters<TEvents[P][number]>[number]>): EventEmitter<TEvents>
  • prependListener(event: string, listener: CallableFunction): EventEmitter<TEvents>
  • prependOnceListener<P>(event: P, listener: Listener<Parameters<TEvents[P][number]>[number]>): EventEmitter<TEvents>
  • prependOnceListener(event: string, listener: CallableFunction): EventEmitter<TEvents>

Generated using TypeDoc