Interface EventEmitter

    • Method Summary

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

      • on

        int on​(java.lang.String eventType,
               EventListener listener)
        Register an event listener to be called when an EventType is emitted.
        Parameters:
        eventType -
        listener -
        Returns:
        a unique token that can be used to unregister the listener.
        See Also:
        EventListener
      • once

        int once​(java.lang.String eventType,
                 EventListener listener)
        Similar to on, except that the listener will be removed after processing one event.
        Parameters:
        eventType -
        listener -
        Returns:
        A token, which can be used later to turn the listener off.
        See Also:
        EventListener
      • off

        void off()
        De-register all listeners.
      • off

        void off​(java.lang.String eventType,
                 int token)
        Unregister a listener from listening to an event type. Uses a unique token to identify which listener to remove.
        Parameters:
        eventType -
        token -
      • emit

        void emit​(java.lang.String eventType)
        Emits an Event.
        Parameters:
        eventType -
      • emit

        void emit​(java.lang.String eventType,
                  java.util.Map<java.lang.String,​java.lang.Object> properties)
        Emits an event with a dynamic properties Map.
        Parameters:
        eventType -
        properties -
      • emitNow

        @MainThread
        void emitNow​(java.lang.String eventType,
                     java.util.Map<java.lang.String,​java.lang.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

        void request​(java.lang.String eventType,
                     EventListener listener)
        Requests a response from the first listener to respond. The response is handled by the provided listener, after which the listener is removed.
        Parameters:
        eventType - The type of Event to emit and expect a response from.
        listener - A listener to process the response. After processing, the response should be removed.
        See Also:
        EventListener
      • request

        void request​(java.lang.String eventType,
                     java.util.Map<java.lang.String,​java.lang.Object> properties,
                     EventListener listener)
        Request a response from the first listener to respond. The response is handled by the provided listener, after which the listener is removed. The provided properties map is passed on to 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. After processing, the response should be removed
        See Also:
        EventListener
      • respond

        void respond​(java.util.Map<java.lang.String,​java.lang.Object> properties)
        Respond to a request. Should be placed within an EventListener and via some means (e.g. the token of an InvocationContainer) know which Request Listener to respond to.
        Parameters:
        properties -
      • respond

        void respond​(Event event)
        Respond to a request. Should be called within an EventListener and given an Event object with the appropriate REQUEST_TOKEN value.
        Parameters:
        event - An Event object with, at minimum, the necessary REQUEST_TOKEN value
      • enable

        void enable()
        Enables listener registration and event emitting.
      • disable

        void disable()
        Disables listener registration and event emitting.