Abin Manathoor Devasia
Abin Manathoor Devasia

Reputation: 1973

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

Upvotes: 6

Views: 1969

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64561

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.

Upvotes: 12

Related Questions