Package meteordevelopment.orbit
Interface IEventBus
- All Known Implementing Classes:
EventBus
public interface IEventBus
Manages event listeners.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanisListening(Class<?> eventClass) Returns whether at least one event listener is currently registered for this event type.<T> Tpost(T event) Posts an event to all subscribed event listeners.voidregisterLambdaFactory(String packagePrefix, LambdaListener.Factory factory) Registers a lambda factory to use with the specified package.voidFinds all correct (static only) methods withEventHandlerannotation and subscribes them.voidFinds all correct (static and non-static) methods withEventHandlerannotation and subscribes them.voidSubscribes the listener (both static and non-static).voidunsubscribe(Class<?> klass) Finds all correct (static only) methods withEventHandlerannotation and unsubscribes them.voidunsubscribe(Object object) Finds all correct (static and non-static) methods withEventHandlerannotation and unsubscribes them.voidunsubscribe(IListener listener) Unsubscribes the listener (both static and non-static).
-
Method Details
-
registerLambdaFactory
Registers a lambda factory to use with the specified package.- Parameters:
packagePrefix- Package prefix that this factory will be used for, eg "meteordevelopment.orbit"factory- The factory to use
-
isListening
Returns whether at least one event listener is currently registered for this event type.- Parameters:
eventClass- The event type to check for registered listeners.- Returns:
- whether the event is being listened for
- Since:
- 0.2.4
-
post
<T> T post(T event) Posts an event to all subscribed event listeners.- Type Parameters:
T- Type of the event- Parameters:
event- Event to post- Returns:
- Event passed in
-
post
Posts a cancellable event to all subscribed event listeners. Stops after the event was cancelled.- Type Parameters:
T- Type of the event- Parameters:
event- Event to post- Returns:
- Event passed in
-
subscribe
Finds all correct (static and non-static) methods withEventHandlerannotation and subscribes them.- Parameters:
object- The object to scan for methods
-
subscribe
Finds all correct (static only) methods withEventHandlerannotation and subscribes them.- Parameters:
klass- The class to scan for methods
-
subscribe
Subscribes the listener (both static and non-static).- Parameters:
listener- Listener to subscribe
-
unsubscribe
Finds all correct (static and non-static) methods withEventHandlerannotation and unsubscribes them.- Parameters:
object- The object to scan for methods
-
unsubscribe
Finds all correct (static only) methods withEventHandlerannotation and unsubscribes them.- Parameters:
klass- The class to scan for methods
-
unsubscribe
Unsubscribes the listener (both static and non-static).- Parameters:
listener- Listener to unsubscribe
-