Interface EventBus


public interface EventBus
The event bus. This is used to register event listeners/handlers for handling events that may be fired by TAB.
  • Method Summary

    Modifier and Type
    Method
    Description
    <E extends TabEvent>
    void
    register(Class<E> type, EventHandler<E> handler)
    Registers the given handler to this event bus.
    void
    register(Object listener)
    Scans the given listener for any method that is annotated with Subscribe and registers it as a listener to this event bus.
    void
    unregister(Object listener)
    Scans the given listener for any method that is annotated with Subscribe and unregisters it from this event bus.
    <E extends TabEvent>
    void
    Unregisters the given handler from this event bus.
  • Method Details

    • register

      void register(Object listener)
      Scans the given listener for any method that is annotated with Subscribe and registers it as a listener to this event bus. All methods in this class that are annotated with Subscribe must meet the following criteria:
      • It must be public.
      • It must not be abstract.
      • It must have exactly one parameter.
      • Its single parameter must be an event.
      If a method does not meet the above criteria, an exception will be thrown.
      Parameters:
      listener - the listener to register
      Throws:
      RuntimeException - if a method does not meet the criteria
    • register

      <E extends TabEvent> void register(Class<E> type, EventHandler<E> handler)
      Registers the given handler to this event bus.
      Type Parameters:
      E - the type of the event
      Parameters:
      type - the class type of the event
      handler - the handler to register
    • unregister

      void unregister(Object listener)
      Scans the given listener for any method that is annotated with Subscribe and unregisters it from this event bus.
      Parameters:
      listener - the listener to unregister
    • unregister

      <E extends TabEvent> void unregister(EventHandler<E> handler)
      Unregisters the given handler from this event bus.
      Type Parameters:
      E - the type of the event
      Parameters:
      handler - the handler to unregister