Add Callback Event Handling #26
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "f/callback-handler"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The EventHandler class has been converted to an interface, with the reflection specific part being moved to the new ReflectiveEventHandler class. Callback event handlers implement the same interface through the CallbackEventHandler class.
The event handlers are defined in the new handler package, which is not exported by the
eventbus.core
module.Closes #21
@ -241,0 +277,4 @@
* @since 1.2.0
* @see #registerListener(Class, Consumer, boolean, int)
*/
public <E> void registerListener(Class<E> eventType, Consumer<E> callback,
Consumer<E> eventListener
?@ -241,0 +293,4 @@
* @since 1.2.0
* @see #registerListener(Class, Consumer, boolean, int)
*/
public <E> void registerListener(Class<E> eventType, Consumer<E> callback, int priority) {
eventListener?
@ -241,0 +307,4 @@
* @param priority the priority to assign to the listener
* @since 1.2.0
*/
public <E> void registerListener(Class<E> eventType, Consumer<E> callback, boolean polymorphic,
eventListener?
@ -0,0 +9,4 @@
* @author Kai S. K. Engelbart
* @since 1.2.0
*/
public class CallbackEventHandler implements EventHandler {
final?
@ -0,0 +12,4 @@
public class CallbackEventHandler implements EventHandler {
private final Class<?> eventType;
private final Consumer<Object> callback;
What about Consumer ?
This wouldn't work, as `callback.accept(event)' would complain about an incompatible argument type.
@ -0,0 +20,4 @@
* Constructs a callback event handler.
*
* @param <E> the event type of the handler
* @param eventType the event type of the handler
😆
@ -0,0 +30,4 @@
public <E> CallbackEventHandler(Class<E> eventType, Consumer<E> callback, boolean polymorphic,
int priority) {
this.eventType = eventType;
this.callback = (Consumer<Object>) callback;
😆
@ -0,0 +45,4 @@
int getPriority();
/**
* @return whether this handler is polymorphic
... accepts subtypes of the event type as well