public interface EventPublisher
Modifier and Type | Method and Description |
---|---|
<E extends Event> |
addEventListener(java.lang.Class<E> eventClass,
CallableWithArgs<?> listener)
Deprecated.
use the
RunnableWithArgs variant instead. |
<E extends Event> |
addEventListener(java.lang.Class<E> eventClass,
RunnableWithArgs listener)
Adds a callable as an event listener.
|
void |
addEventListener(java.util.Map<java.lang.String,java.lang.Object> listener)
Adds a Map containing event listeners.
|
void |
addEventListener(java.lang.Object listener)
Adds an event listener.
|
void |
addEventListener(java.lang.String eventName,
CallableWithArgs<?> listener)
Deprecated.
use the
RunnableWithArgs variant instead. |
void |
addEventListener(java.lang.String eventName,
RunnableWithArgs listener)
Adds a callable as an event listener.
|
java.util.Collection<java.lang.Object> |
getEventListeners()
Returns an immutable snapshot view of all event listeners registered.
|
java.util.Collection<java.lang.Object> |
getEventListeners(java.lang.String eventName)
Returns an immutable snapshot view of all event listeners registered for the target event name.
|
boolean |
isEventPublishingEnabled()
Returns whether events will be published by the event bus or not.
|
void |
publishEvent(Event event)
Publishes an event.
|
void |
publishEvent(java.lang.String eventName)
Publishes an event.
|
void |
publishEvent(java.lang.String eventName,
java.util.List<?> args)
Publishes an event.
|
void |
publishEventAsync(Event event)
Publishes an event.
|
void |
publishEventAsync(java.lang.String eventName)
Publishes an event.
|
void |
publishEventAsync(java.lang.String eventName,
java.util.List<?> args)
Publishes an event.
|
void |
publishEventOutsideUI(Event event)
Publishes an event.
|
void |
publishEventOutsideUI(java.lang.String eventName)
Publishes an event.
|
void |
publishEventOutsideUI(java.lang.String eventName,
java.util.List<?> args)
Publishes an event.
|
<E extends Event> |
removeEventListener(java.lang.Class<E> eventClass,
CallableWithArgs<?> listener)
Deprecated.
use the
RunnableWithArgs variant instead. |
<E extends Event> |
removeEventListener(java.lang.Class<E> eventClass,
RunnableWithArgs listener)
Removes a callable as an event listener.
|
void |
removeEventListener(java.util.Map<java.lang.String,java.lang.Object> listener)
Removes a Map containing event listeners.
|
void |
removeEventListener(java.lang.Object listener)
Removes an event listener.
|
void |
removeEventListener(java.lang.String eventName,
CallableWithArgs<?> listener)
Deprecated.
use the
RunnableWithArgs variant instead. |
void |
removeEventListener(java.lang.String eventName,
RunnableWithArgs listener)
Removes a callable as an event listener.
|
void |
setEventPublishingEnabled(boolean enabled)
Sets the enabled state for event publishing.
|
void addEventListener(@Nonnull java.lang.Object listener)
Accepted types are: Script, Map and Object.
listener
- an event listenervoid addEventListener(@Nonnull java.lang.String eventName, @Nonnull RunnableWithArgs listener)
eventName
- the name of the eventlistener
- an event listener@Deprecated void addEventListener(@Nonnull java.lang.String eventName, @Nonnull CallableWithArgs<?> listener)
RunnableWithArgs
variant instead.eventName
- the name of the eventlistener
- an event listenervoid addEventListener(@Nonnull java.util.Map<java.lang.String,java.lang.Object> listener)
An event listener may be
Maps require handlers to be named as eventName only.
Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Map@Deprecated <E extends Event> void addEventListener(@Nonnull java.lang.Class<E> eventClass, @Nonnull CallableWithArgs<?> listener)
RunnableWithArgs
variant instead.eventClass
- the type of the eventlistener
- an event listener<E extends Event> void addEventListener(@Nonnull java.lang.Class<E> eventClass, @Nonnull RunnableWithArgs listener)
eventClass
- the type of the eventlistener
- an event listenervoid removeEventListener(@Nonnull java.lang.Object listener)
Accepted types are: Script, Map and Object.
listener
- an event listenervoid removeEventListener(@Nonnull java.lang.String eventName, @Nonnull RunnableWithArgs listener)
eventName
- the name of the eventlistener
- an event listener@Deprecated void removeEventListener(@Nonnull java.lang.String eventName, @Nonnull CallableWithArgs<?> listener)
RunnableWithArgs
variant instead.eventName
- the name of the eventlistener
- an event listenervoid removeEventListener(@Nonnull java.util.Map<java.lang.String,java.lang.Object> listener)
An event listener may be
Maps require handlers to be named as eventName only.
Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.
listener
- an event listener of type Map<E extends Event> void removeEventListener(@Nonnull java.lang.Class<E> eventClass, @Nonnull RunnableWithArgs listener)
eventClass
- the type of the eventlistener
- an event listener@Deprecated <E extends Event> void removeEventListener(@Nonnull java.lang.Class<E> eventClass, @Nonnull CallableWithArgs<?> listener)
RunnableWithArgs
variant instead.eventClass
- the type of the eventlistener
- an event listenervoid publishEvent(@Nonnull java.lang.String eventName)
Listeners will be notified in the same thread as the publisher.
eventName
- the name of the eventvoid publishEvent(@Nonnull java.lang.String eventName, @Nullable java.util.List<?> args)
Listeners will be notified in the same thread as the publisher.
eventName
- the name of the eventargs
- event arguments sent to listenersvoid publishEvent(@Nonnull Event event)
Listeners will be notified in the same thread as the publisher.
event
- the event to be publishedvoid publishEventOutsideUI(@Nonnull java.lang.String eventName)
Listeners will be notified outside of the UI thread.
eventName
- the name of the eventvoid publishEventOutsideUI(@Nonnull java.lang.String eventName, @Nullable java.util.List<?> args)
Listeners will be notified outside of the UI thread.
eventName
- the name of the eventargs
- event arguments sent to listenersvoid publishEventOutsideUI(@Nonnull Event event)
Listeners will be notified outside of the UI thread.
event
- the event to be publishedvoid publishEventAsync(@Nonnull java.lang.String eventName)
Listeners will be notified in a different thread.
eventName
- the name of the eventvoid publishEventAsync(@Nonnull java.lang.String eventName, @Nullable java.util.List<?> args)
Listeners will be notified in a different thread.
eventName
- the name of the eventargs
- event arguments sent to listenersvoid publishEventAsync(@Nonnull Event event)
Listeners will be notified in a different thread.
event
- the event to be publishedboolean isEventPublishingEnabled()
void setEventPublishingEnabled(boolean enabled)
enabled
- the value fot the enabled state.@Nonnull java.util.Collection<java.lang.Object> getEventListeners()
@Nonnull java.util.Collection<java.lang.Object> getEventListeners(@Nonnull java.lang.String eventName)
eventName
- the name of the event