When i working with one GWT project am using MVP pattern
and HandlerManager
for communicating on the application via Events. Now am implementing History Machanisam on my project.
They(GWT tearm) used Class EventBus
for managing the events.
When read some blog i foud HandlerManger
is used for Widgets
and EventBus
for other application wide communication.
But i feel both of them have same functionalities, then whats the purpose of this two implemetations, or whats the difference between them .
please help me
HandlerManager
is the ancestor of the EventBus
, which was extracted from (factored out of) it.
The main difference is that a HandlerManager
has a source that it enforces on the events being dispatched to it, whereas EventBus
can dispatch events with no source (fireEvent
) or with a given dynamic source (fireEventFromSource
). You can then attach handlers to the EventBus
that will only be triggered for events from a given source.
Within widgets, you want to enforce that the event source is the widget. For a global application-wide event bus, you either want no source, or a source dynamically set for each event, as needed (RequestFactory
uses it for its EntityProxyChange
events so you can listen only to events related to a given kind of EntityProxy
)
Note: the javadoc for HandlerManager
discourages using it for an application-wide event bus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With