Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • EventEmitter

Index

Constructors

  • Parameters

    • Optional subscriber: null | EventSubscriptionVendor

      Optional subscriber instance to use. If omitted, a new subscriber will be created for the emitter.

    Returns EventEmitter

Methods

  • addListener(eventType: string, listener: (...args: any[]) => any, context?: any): EmitterSubscription
  • Adds a listener to be invoked when events of the specified type are emitted. An optional calling context may be provided. The data arguments emitted will be passed to the listener function.

    Parameters

    • eventType: string

      Name of the event to listen to

    • listener: (...args: any[]) => any

      Function to invoke when the specified event is emitted

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional context: any

      Optional context object to use when invoking the listener

    Returns EmitterSubscription

  • emit(eventType: string, ...params: any[]): void
  • Emits an event of the given type with the given data. All handlers of that particular type will be notified.

    example

    emitter.addListener('someEvent', function(message) { console.log(message); });

    emitter.emit('someEvent', 'abc'); // logs 'abc'

    Parameters

    • eventType: string

      Name of the event to emit

    • Rest ...params: any[]

    Returns void

  • listenerCount(eventType: string): number
  • Returns the number of listeners that are currently registered for the given event.

    Parameters

    • eventType: string

      Name of the event to query

    Returns number

  • removeAllListeners(eventType?: string): void
  • Removes all of the registered listeners, including those registered as listener maps.

    Parameters

    • Optional eventType: string

      Optional name of the event whose registered listeners to remove

    Returns void

Generated using TypeDoc