Event Bus
Central event dispatch interface.
val bus = EventBus()
bus.subscribe(MyListener())
bus.post(MyEvent())Java:
EventBus bus = EventBus.create();
bus.subscribe(new MyListener());
bus.post(new MyEvent());
// With async dispatch:
EventBus bus = EventBus.create(Executors.newVirtualThreadPerTaskExecutor());Handlers are registered via annotation scanning (subscribe) or lambda (subscribe overloads). For Cancellable events, dispatch stops as soon as any handler sets Cancellable.isCancelled to true. Exceptions thrown inside handlers are routed to the configured exceptionHandler and never propagate out of post or postAsync.
Functions
Returns true if at least one handler is registered for eventClass or any of its supertypes.
Returns true if at least one wildcard handler is currently registered.
Dispatches event asynchronously and returns a CompletableFuture that completes with the event once all handlers have finished.
Registers all instance methods on subscriber annotated with @Subscribe.
Registers a Consumer handler for eventClass with synchronous dispatch.
Registers a lambda handler for eventClass with synchronous dispatch.
Registers a Consumer handler for eventClass and returns a Subscription token.
Registers a lambda handler for eventClass and returns a Subscription token.
Registers a wildcard Consumer handler that fires for every posted event.
Registers a wildcard handler that fires for every posted event regardless of type.
Registers a wildcard handler with Priority.NORMAL as the default priority.
Registers all static methods on klass annotated with @Subscribe.
Removes all instance handlers previously registered for subscriber.
Removes all registered handlers from this bus: instance, static, lambda, and wildcard.
Removes all static handlers previously registered for klass.