Package 

Interface EventEmitter


  • 
    public interface EventEmitter
    
                        

    Defines the public facing api for classes that wish to emit events. See EventEmitterImpl for the main implementation method descriptions.

    • Method Summary

      Modifier and Type Method Description
      abstract int on(String eventType, EventListener listener) Register an event listener to be called when an EventType is emitted.
      abstract int once(String eventType, EventListener listener) Similar to on, except that the listener will be removed afterprocessing one event.
      abstract void off() De-register all listeners.
      abstract void off(String eventType, int token) Unregister a listener from listening to an event type.
      abstract void emit(String eventType) Emits an Event.
      abstract void emit(String eventType, Map<String, Object> properties) Emits an event with a dynamic properties Map.
      abstract void emitNow(String eventType, Map<String, Object> properties) Emits an event immediately instead of waiting for the handler.
      abstract void request(String eventType, EventListener listener) Requests a response from the first listener to respond.
      abstract void request(String eventType, Map<String, Object> properties, EventListener listener) Request a response from the first listener to respond.
      abstract void respond(Map<String, Object> properties) Respond to a request.
      abstract void respond(Event event) Respond to a request.
      abstract void enable() Enables listener registration and event emitting.
      abstract void disable() Disables listener registration and event emitting.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • on

         abstract int on(String eventType, EventListener listener)

        Register an event listener to be called when an EventType is emitted.

      • once

         abstract int once(String eventType, EventListener listener)

        Similar to on, except that the listener will be removed afterprocessing one event.

      • off

         abstract void off()

        De-register all listeners.

      • off

         abstract void off(String eventType, int token)

        Unregister a listener from listening to an event type. Uses aunique token to identify which listener to remove.

      • emit

         abstract void emit(String eventType)

        Emits an Event.

      • emitNow

        @MainThread() abstract void emitNow(String eventType, Map<String, Object> properties)

        Emits an event immediately instead of waiting for the handler.

        Parameters:
        eventType - The event type.
        properties - The properties to send when processing the event.
      • request

         abstract void request(String eventType, EventListener listener)

        Requests a response from the first listener to respond. The response is handled by the provided listener, afterwhich the listener is removed.

        Parameters:
        eventType - The type of Event to emit and expect a response from.
        listener - A listener to process the response.
      • request

         abstract void request(String eventType, Map<String, Object> properties, EventListener listener)

        Request a response from the first listener to respond. Theresponse is handled by the provided listener, after which thelistener is removed. The provided properties map is passed onto the responding listener

        Parameters:
        eventType - The type of Event to emit and expect a response from.
        properties - A Map of properties to pass along the event chain
        listener - A listener to process the response.
      • respond

         abstract void respond(Map<String, Object> properties)

        Respond to a request. Should be placed within an EventListenerand via some means (e.g. the token of an InvocationContainer)know which Request Listener to respond to.

      • respond

         abstract void respond(Event event)

        Respond to a request. Should be called within an EventListenerand given an Event object with the appropriate REQUEST_TOKENvalue.

        Parameters:
        event - An Event object with, at minimum, the necessary REQUEST_TOKEN value
      • enable

         abstract void enable()

        Enables listener registration and event emitting.

      • disable

         abstract void disable()

        Disables listener registration and event emitting.