Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event Bus Vs HandlerManager in GWT?

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

like image 314
Abin Manathoor Devasia Avatar asked Oct 03 '13 08:10

Abin Manathoor Devasia


1 Answers

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.

like image 171
Thomas Broyer Avatar answered Oct 18 '22 11:10

Thomas Broyer