public abstract class AbstractEventPublisher extends Object implements EventPublisher
Constructor and Description |
---|
AbstractEventPublisher() |
Modifier and Type | Method and Description |
---|---|
<E extends Event> |
addEventListener(Class<E> eventClass,
CallableWithArgs<?> listener)
Adds a callable as an event listener.
|
<E extends Event> |
addEventListener(Class<E> eventClass,
RunnableWithArgs listener)
Adds a callable as an event listener.
|
void |
addEventListener(Map<String,Object> listener)
Adds a Map containing event listeners.
|
void |
addEventListener(Object listener)
Adds an event listener.
|
void |
addEventListener(String eventName,
CallableWithArgs<?> listener)
Adds a callable as an event listener.
|
void |
addEventListener(String eventName,
RunnableWithArgs listener)
Adds a callable as an event listener.
|
boolean |
isEventPublishingEnabled()
Returns whether events will be published by the event bus or not.
|
void |
publishEvent(Event event)
Publishes an event.
|
void |
publishEvent(String eventName)
Publishes an event.
|
void |
publishEvent(String eventName,
List<?> params)
Publishes an event.
|
void |
publishEventAsync(Event event)
Publishes an event.
|
void |
publishEventAsync(String eventName)
Publishes an event.
|
void |
publishEventAsync(String eventName,
List<?> params)
Publishes an event.
|
void |
publishEventOutsideUI(Event event)
Publishes an event.
|
void |
publishEventOutsideUI(String eventName)
Publishes an event.
|
void |
publishEventOutsideUI(String eventName,
List<?> params)
Publishes an event.
|
<E extends Event> |
removeEventListener(Class<E> eventClass,
CallableWithArgs<?> listener)
Removes a callable as an event listener.
|
<E extends Event> |
removeEventListener(Class<E> eventClass,
RunnableWithArgs listener)
Removes a callable as an event listener.
|
void |
removeEventListener(Map<String,Object> listener)
Removes a Map containing event listeners.
|
void |
removeEventListener(Object listener)
Removes an event listener.
|
void |
removeEventListener(String eventName,
CallableWithArgs<?> listener)
Removes a callable as an event listener.
|
void |
removeEventListener(String eventName,
RunnableWithArgs listener)
Removes a callable as an event listener.
|
void |
setEventPublishingEnabled(boolean enabled)
Sets the enabled state for event publishing.
|
void |
setEventRouter(EventRouter eventRouter) |
@Inject public void setEventRouter(@Nonnull EventRouter eventRouter)
public boolean isEventPublishingEnabled()
EventPublisher
isEventPublishingEnabled
in interface EventPublisher
public void setEventPublishingEnabled(boolean enabled)
EventPublisher
setEventPublishingEnabled
in interface EventPublisher
enabled
- the value fot the enabled state.public <E extends Event> void removeEventListener(@Nonnull Class<E> eventClass, @Nonnull CallableWithArgs<?> listener)
EventPublisher
removeEventListener
in interface EventPublisher
eventClass
- the type of the eventlistener
- an event listenerpublic <E extends Event> void removeEventListener(@Nonnull Class<E> eventClass, @Nonnull RunnableWithArgs listener)
EventPublisher
removeEventListener
in interface EventPublisher
eventClass
- the type of the eventlistener
- an event listenerpublic void addEventListener(@Nonnull Object listener)
EventPublisher
Accepted types are: Script, Map and Object.
addEventListener
in interface EventPublisher
listener
- an event listenerpublic void addEventListener(@Nonnull String eventName, @Nonnull CallableWithArgs<?> listener)
EventPublisher
addEventListener
in interface EventPublisher
eventName
- the name of the eventlistener
- an event listenerpublic void addEventListener(@Nonnull String eventName, @Nonnull RunnableWithArgs listener)
EventPublisher
addEventListener
in interface EventPublisher
eventName
- the name of the eventlistener
- an event listenerpublic void publishEvent(@Nonnull String eventName)
EventPublisher
Listeners will be notified in the same thread as the publisher.
publishEvent
in interface EventPublisher
eventName
- the name of the eventpublic void publishEventOutsideUI(@Nonnull Event event)
EventPublisher
Listeners will be notified outside of the UI thread.
publishEventOutsideUI
in interface EventPublisher
event
- the event to be publishedpublic void removeEventListener(@Nonnull Map<String,Object> listener)
EventPublisher
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.
removeEventListener
in interface EventPublisher
listener
- an event listener of type Mappublic <E extends Event> void addEventListener(@Nonnull Class<E> eventClass, @Nonnull CallableWithArgs<?> listener)
EventPublisher
addEventListener
in interface EventPublisher
eventClass
- the type of the eventlistener
- an event listenerpublic <E extends Event> void addEventListener(@Nonnull Class<E> eventClass, @Nonnull RunnableWithArgs listener)
EventPublisher
addEventListener
in interface EventPublisher
eventClass
- the type of the eventlistener
- an event listenerpublic void publishEventOutsideUI(@Nonnull String eventName)
EventPublisher
Listeners will be notified outside of the UI thread.
publishEventOutsideUI
in interface EventPublisher
eventName
- the name of the eventpublic void publishEventOutsideUI(@Nonnull String eventName, @Nullable List<?> params)
EventPublisher
Listeners will be notified outside of the UI thread.
publishEventOutsideUI
in interface EventPublisher
eventName
- the name of the eventparams
- event arguments sent to listenerspublic void publishEvent(@Nonnull String eventName, @Nullable List<?> params)
EventPublisher
Listeners will be notified in the same thread as the publisher.
publishEvent
in interface EventPublisher
eventName
- the name of the eventparams
- event arguments sent to listenerspublic void publishEventAsync(@Nonnull String eventName, @Nullable List<?> params)
EventPublisher
Listeners will be notified in a different thread.
publishEventAsync
in interface EventPublisher
eventName
- the name of the eventparams
- event arguments sent to listenerspublic void removeEventListener(@Nonnull String eventName, @Nonnull CallableWithArgs<?> listener)
EventPublisher
removeEventListener
in interface EventPublisher
eventName
- the name of the eventlistener
- an event listenerpublic void removeEventListener(@Nonnull String eventName, @Nonnull RunnableWithArgs listener)
EventPublisher
removeEventListener
in interface EventPublisher
eventName
- the name of the eventlistener
- an event listenerpublic void removeEventListener(@Nonnull Object listener)
EventPublisher
Accepted types are: Script, Map and Object.
removeEventListener
in interface EventPublisher
listener
- an event listenerpublic void addEventListener(@Nonnull Map<String,Object> listener)
EventPublisher
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.
addEventListener
in interface EventPublisher
listener
- an event listener of type Mappublic void publishEvent(@Nonnull Event event)
EventPublisher
Listeners will be notified in the same thread as the publisher.
publishEvent
in interface EventPublisher
event
- the event to be publishedpublic void publishEventAsync(@Nonnull String eventName)
EventPublisher
Listeners will be notified in a different thread.
publishEventAsync
in interface EventPublisher
eventName
- the name of the eventpublic void publishEventAsync(@Nonnull Event event)
EventPublisher
Listeners will be notified in a different thread.
publishEventAsync
in interface EventPublisher
event
- the event to be published