Event Bus Vs HandlerManager in GWT?

When I work with one GWT project, I use MVP pattern and HandlerManager to communicate in the application through Events. Now I use History Machanisam in my project. They (GWT tearm) used the EventBus class to manage events.

When you read a blog, I use foud HandlerManger for Widgets and EventBus for communicating with other applications.

But I feel that both of them have the same functionality, what is the purpose of these two implementations or what is the difference between them.

Please help me

+6
source share
1 answer

HandlerManager is the ancestor of the EventBus , which was extracted from (factored out) from it.

The main difference is that the HandlerManager has a source that for execution on events that are sent to it, while the EventBus can send events without any source ( fireEvent ) or with a given dynamic source ( fireEventFromSource ). Then you can bind handlers to EventBus , which will be triggered only for events from this source.

Inside the widgets you want to determine that the event source is the widget. For a global application event bus on a scale, you don’t or don’t want to dynamically set a source or source for each event, if necessary ( RequestFactory uses it for its EntityProxyChange events, so you can only listen to the event associated with this view of EntityProxy )

Note: javadoc for HandlerManager does not recommend using it for a common event bus.

+12
source

Source: https://habr.com/ru/post/955171/


All Articles