Monday, September 13, 2010

Gwt: when use Event Bus?

It's important to keep in mind that not all events should be placed on the Event Bus. Blindly dumping all of the possible events within your app on the Event Bus can lead to chatty applications that get bogged down in event handling. Not to mention, you'll find yourself writing a fair amount of boiler plate code to define, source, sink, and act upon these events.

App-wide events are really the only events that you want to be passing around on the Event Bus. The app is uninterested in events such as "the user clicked enter" or "an RPC is about to be made". Instead (at least in our example app), we pass around events such as a contact being updated, the user switching to the edit view, or an RPC to delete a user successfully returning from the server.

Below is a list of the events that we have defined.

  • AddContactEvent
  • ContactDeletedEvent
  • ContactUpdatedEvent
  • EditContactCancelledEvent
  • EditContactEvent

Above content is from

So UI level event should not be put into event bus. For example, you have two linked list box, the changes on the first list box will change the items of the second list box. This event should not be put in event bus.

No comments:

Post a Comment