Sunday, May 19, 2019

An EventBus with less boiler plate

Apologies if this has been discussed before. The EventBus requires the declaration of an Event class and a Handler interface for each activity of interest, which often results in plenty of boiler plate. In one of our projects we came up with a simpler notation which doesn't require event classes - so all we write are Handler interfaces (and their implementations). This does however require a modified event bus.

Firing an event can be as simple as:

bus.fireEvent(Types.transactionEvents, (l)->l.deposit(depositDate, 150, "ATM"));

The traditonal event/handler design template always implements these steps:

- sender package data into an event
- sender fires event on the event bus
- event bus locates handlers and executes event on them
- event invokes a method on the handler and passes packaged data as arguments

The idea here is that it is slightly less work to directly invoke a listener method with the appropriate arguments instead of going through the event pack/unpack procedure.

The repo is here:, feel free to use any way you like.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment