Class EventBus
java.lang.Object
pro.gravit.launcher.base.modules.EventBus
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA clean API for unregistering handlers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidhandleException(Exception e, Object event, Consumer<Object> handler) Extension point for centralized error handling without interrupting other listeners.voidPublishes an event to all registered handlers of its exact type, superclasses, and interfaces.Registers a handler for a specific event type.
-
Constructor Details
-
EventBus
public EventBus()
-
-
Method Details
-
register
Registers a handler for a specific event type.- Parameters:
eventType- The class of the event to listen forhandler- The logic to execute when the event is received- Returns:
- A Subscription object used to unregister the handler
-
publish
Publishes an event to all registered handlers of its exact type, superclasses, and interfaces. -
handleException
-