Class EventBus

java.lang.Object
pro.gravit.launcher.base.modules.EventBus

public class EventBus extends Object
  • Constructor Details

    • EventBus

      public EventBus()
  • Method Details

    • register

      public <T> EventBus.Subscription register(Class<T> eventType, Consumer<T> handler)
      Registers a handler for a specific event type.
      Parameters:
      eventType - The class of the event to listen for
      handler - The logic to execute when the event is received
      Returns:
      A Subscription object used to unregister the handler
    • publish

      public void publish(Object event)
      Publishes an event to all registered handlers of its exact type, superclasses, and interfaces.
    • handleException

      protected void handleException(Exception e, Object event, Consumer<Object> handler)
      Extension point for centralized error handling without interrupting other listeners.