Package net.runelite.client.eventbus
Class EventBus
- java.lang.Object
-
- net.runelite.client.eventbus.EventBus
-
- Direct Known Subclasses:
DeferredEventBus
@ThreadSafe public class EventBus extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventBus.Subscriber
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
post(Object event)
Posts provided event to all registered subscribers.<T> EventBus.Subscriber
register(Class<T> clazz, Consumer<T> subFn, float priority)
void
register(Object object)
Registers subscriber to EventBus.void
unregister(Object object)
Unregisters all subscribed methods from provided subscriber object.void
unregister(EventBus.Subscriber sub)
-
-
-
Method Detail
-
register
public void register(@Nonnull Object object)
Registers subscriber to EventBus. All methods in subscriber and it's parent classes are checked forSubscribe
annotation and then added to map of subscriptions.- Parameters:
object
- subscriber to register- Throws:
IllegalArgumentException
- in case subscriber method name is wrong (correct format is 'on' + EventName
-
register
public <T> EventBus.Subscriber register(Class<T> clazz, Consumer<T> subFn, float priority)
-
unregister
public void unregister(@Nonnull Object object)
Unregisters all subscribed methods from provided subscriber object.- Parameters:
object
- object to unsubscribe from
-
unregister
public void unregister(EventBus.Subscriber sub)
-
post
public void post(@Nonnull Object event)
Posts provided event to all registered subscribers. Subscriber calls are invoked immediately, ordered by priority then their declaring class' name.- Parameters:
event
- event to post
-
-