classSource
public final class EventBusConstructors
public EventBus()Methods
void post(Event)void subscribe(Class, EventListener)Example usage:void unsubscribe(Class, EventListener)public <T extends Event> void post(T event)| Parameters | ||
|---|---|---|
event | T | |
public <T extends Event> void subscribe(Class<T> type, EventListener<T> listener)Example usage:
// replace SomeEvent with any event you'd like to listen to
eventBus.subscribe(SomeEvent.class, event -> {
// Code here will get executed when the event gets triggered
});| Parameters | ||
|---|---|---|
type | Class<T> | |
listener | EventListener<T> | |
public <T extends Event> void unsubscribe(Class<T> type, EventListener<T> listener)| Parameters | ||
|---|---|---|
type | Class<T> | |
listener | EventListener<T> | |
Used by
Methods of other types that accept or return EventBus.