@ComponentSpecification public interface EventBus
sending
,
listening
to and receiving
Event
s. The EventBus
allows to communicate between loosely coupled components in a smart and
efficient way:
EventBus
but not the receivers of the events.EventBus
but not the sender of the events.Event
s without compile time dependency between them. All they need to
see is the EventBus
and the Event
itself. mmm-client
. If you want to write a portable
client application that can run in different environments (GWT, JavaFx, etc.) then you should use this simplified but
normalized API. Otherwise you may want to use an external event bus implementation directly such as
guava event bus. EventBus
to update their views accordingly. However, a business component responsible to read and write
addresses may get the requirement that in case of a change of an address some logic from the domain of another
component should be invoked and that might even reject the change. In the latter case EventBus
is the wrong
choice.Modifier and Type | Method and Description |
---|---|
<E> void |
addListener(Class<E> eventType,
EventListener<E> listener)
This method registers a listener that is interested in
Event s. |
boolean |
removeListener(EventListener<?> listener)
This method removes a listener.
|
<E> void |
sendEvent(E event)
This method sends an event to all
registered listeners . |
<E> void sendEvent(E event)
registered listeners
.E
- is the generic type of the Event
to send. May be any Object such as a String
. However in
most cases it is recommended to create real Event
classes.event
- is the event to send. May be any Object such as a String
. However in most cases it is
recommended to create real Event
classes.<E> void addListener(Class<E> eventType, EventListener<E> listener)
Event
s.E
- is the generic type of the Event
s to listen to. May be any Object such as a String
.
However in most cases it is recommended to create real Event
classes.eventType
- is the type of the Event
s to listen to (including all derived types). In limited
environments such as GWT, interfaces might not be supported.listener
- is the listener to add.boolean removeListener(EventListener<?> listener)
listener
- is the listener to remove.true
if the given listener
has successfully been removed, false
if the
listener
was NOT registered
.Copyright © 2001–2016 mmm-Team. All rights reserved.