eventbus-kotlin
eventbus-kotlin copied to clipboard
Add support for annotated method listeners
Adds support to automatically create Listener
s using MethodHandles or Reflection from methods that take a single event type and an @EventHandler
annotation.
See the README.md for an example.
@therealbush: The name of @EventHandler
is still very much up for debate with me, I am not really satisfied with this.
looks good, but I will read this over when I am at home.
I forgot about this...
When I first made this I thought about doing some sort of reflective listener invocation but ultimately decided against it because:
A: MethodHandles, LambdaMetaFactory, etc. are fast, but a lambda is still faster. B: Hacky/reflective approaches have more issues and tend to not work on all java versions. C: My first event bus uses LambdaMetaFactory, and I thought it would be cool to make one that is different.
I know this event bus is used by like 3 people so it doesn't really matter, but I am going to decline this PR simply because MethodHandle backed listeners don't do anything that the existing lambda backed listeners don't already do, except maybe having nicer syntax in Java. (in which case, you should check out my Java event bus!)