Added paragraph about static methods in README

This commit is contained in:
Leon Hofmeister 2020-09-25 20:58:15 +02:00
parent f6e5c90a44
commit 93f239e71f

View File

@ -51,6 +51,16 @@ public class SimpleEventListener implements EventListener {
In this case, an event bus is created and used locally. 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. In a more sophisticated example the class would acquire an external event bus that is used by multiple classes.
Note that using static methods like this
```java
@Event
private static void onSimpleEvent(SimpleEvent event) ...
```
is technically possible, yet unwanted in most cases, as you have no access to an instance of the calling class.
## Event handlers for subtypes ## 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. On certain occasions its practical for an event handler to accept both events of the specified type, as well as subclasses of that event.