eventbus-kotlin icon indicating copy to clipboard operation
eventbus-kotlin copied to clipboard

Add support for annotated method listeners

Open nea89o opened this issue 2 years ago • 1 comments

Adds support to automatically create Listeners 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.

nea89o avatar Sep 10 '22 01:09 nea89o

looks good, but I will read this over when I am at home.

therealbush avatar Sep 10 '22 01:09 therealbush

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!)

therealbush avatar Apr 15 '23 23:04 therealbush