- Type Parameters:
T- - root event type
public sealed interface EventBus<T>
An event bus which dispatches events to subscribed handlers.
-
Method Summary
Modifier and TypeMethodDescriptionchildren()create()static <T> EventBus<T>static <T> EventBus<T>static <T> EventBus<T>create(Class<T> eventType, @Nullable ClassHierarchyService hierarchyService) parent()default <E extends T>
voidpublish(E event) <E extends T>
EventContextpublish(E event, EventContext context) default <E extends T>
booleanpublishCancellable(E event) removeChild(EventBus<E> child) subscribe(EventSubscriber<E> subscriber) subscribe(Class<E> eventType, EventHandler<E> handler) subscribe(Class<E> eventType, BiConsumer<E, EventContext> handler) subscribeAnnotated(Object object) Subscribes all method annotated withSubscribedeclared in the specified object.unsubscribe(EventSubscriber<E> subscriber) unsubscribeAnnotated(Object object) Unsubscribes all methods annotated withSubscribedeclared in the specified object.
-
Method Details
-
create
-
create
-
create
-
create
static <T> EventBus<T> create(Class<T> eventType, @Nullable @Nullable ClassHierarchyService hierarchyService) -
publish
-
publishCancellable
-
publish
-
eventType
-
parent
-
children
-
addChild
-
removeChild
-
subscribeAnnotated
Subscribes all method annotated withSubscribedeclared in the specified object. Passing aClassto this method will subscribe static methods, passing an instance will subscribe instance methods.- Parameters:
object- - an object instance or a class- Returns:
- the event bus
-
unsubscribeAnnotated
Unsubscribes all methods annotated withSubscribedeclared in the specified object. Passing aClassto this method will unsubscribe static methods, passing an instance will unsubscribe instance methods.- Parameters:
object- - an object instance or a class- Returns:
- the event bus
-
subscribe
-
subscribe
-
subscribe
-
subscribe
-
unsubscribe
-