Closed ghost closed 10 years ago
We had a similar feature in the generator but didn't release as part of open source release because that kind of behavior is better implemented at EventBus level. It shouldn't be a responsibility of @EventHandler code generator. If you like, you can send a patch for the custom EventBus that provides such behavior.
Thanks for replying.
Maybe I'm missing something, but it's not clear to me how an EventBus implementation could do this -- it wouldn't have access to an Event's type hierarchy at run-time.
Could you elaborate?
Sorry, it may not be obvious. Here how you can do it: On fire event, it can get the parent class of the event and then get the corresponding event type and then re-fire the event with parent event type (recursively).
I agree with Goktug that this library is probably best off as a very thin wrapper around the existing event handling system that doesn't try to add new features. You might also be interested in checking out one of my other experimental projects at https://github.com/ekuefler/gwt-supereventbus, which provides a more powerful event bus to GWT that implements a feature like the polymorphism you suggest here.
Hey there!
I've made some changes to support specifying an @EventHandler for a base, abstract event. The generator just generates an additional bind() call for each subtype (recursively).
This is really great for us because now we can cover entire "classes" of events with just one handler, rather than manually being forced to specify explicit @EventHandlers for each subtype.
Is this something y'all would be interested in? If so, I can tidy things up and send a pull request this week.