It is a real pain to create and use GWT events. There is a lot of boilerplate code that must be generated, including:
- A very heavy Event Class, with static Type class, and a bunch of required methods
- A Handler interface needs to be created as well.
As Errai is on a mission to eliminate boilerplace, it seems like there is good potential for Errai to help out in this area.
This differs from CDI events, in that they are not broadcasts, but they events local to the component that is firing them (the EventBus is a @Dependent scoped bean).
I don't event know if this is implementable as proposed, but I would be curious to get some feedback as to whether this is something that would be of interest, and if it would be difficult to do.
The only class that needs to be created when adding a new event is the actual Event Class. Like CDI events, these are join plain POJOs. There would be ZERO boilerplace (perhaps an annotation, but that's it).
Event Classes are annotated with an @Event annotation
There is an EventBus class which is @Inject ed into the component.
The eventbus has the following interface:
The EventHandler interface is as follows:
Putting it all together, you would have something like this: