Abstract base class for implementing event-emitting modules. This implements a subset of the standard EventEmitter node module API.

Hierarchy

  • default
    • NativeEventEmitter

Constructors

  • Parameters

    • OptionalnativeModule: NativeModule

      the NativeModule implementation. This is required on IOS and will throw an invariant error if undefined.

    Returns NativeEventEmitter

Methods

  • Add the specified listener, this call passes through to the NativeModule addListener

    Parameters

    • eventType: string

      name of the event for which we are registering listener

    • listener: (event: any) => void

      the listener function

    • Optionalcontext: Object

      context of the listener

    Returns EmitterSubscription

  • Emits an event of the given type with the given data. All handlers of that particular type will be notified.

    Parameters

    • eventType: string

      Name of the event to emit

    • ...params: any[]

    Returns void

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

    emitter.emit('someEvent', 'abc'); // logs 'abc'
  • Returns the number of listeners that are currently registered for the given event.

    Parameters

    • eventType: string

      Name of the event to query

    Returns number

  • Parameters

    • eventType: string

      name of the event whose registered listeners to remove

    Returns void

  • Removes a subscription created by the addListener, the EventSubscription#remove() function actually calls through to this.

    Parameters

    Returns void