From cd2598d5d39172c086d4a8578b8bf2816940af8a Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 26 Sep 2020 09:59:08 +0200 Subject: [PATCH] Add Section About Static Methods in README (#2) Add paragraph about static methods in README Co-authored-by: kske Reviewed-on: https://git.kske.dev/zdm/event-bus/pulls/2 Reviewed-by: kske --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 07e8240..a4a7576 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,15 @@ public class SimpleEventListener implements EventListener { In this case, an event bus is created and used locally. In a more sophisticated example the class would acquire an external event bus that is used by multiple classes. +Note that creating static event handlers like this + +```java + @Event + private static void onSimpleEvent(SimpleEvent event) ... +``` + +is technically possible, however you would still have to create an instance of the event listener to register it at an event bus. + ## Event handlers for subtypes On certain occasions its practical for an event handler to accept both events of the specified type, as well as subclasses of that event.