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.