public interface Listener extends EventListener
ListenerStore.
Normally, you create an interface extending Listener and add some
listening methods. By default, those methods must adhere to the
signature:
public void <listeningName>(<subclass of Event> e);This allows you to provide a method reference conforming to the
BiConsumer functional interface to the
dispatch
method of an EventProvider.
eventProvider.dispatch(MyListener.class, someEventInstance,
MyListener::listeningMethod);
To enable compile time checks for whether your listener definition adheres to
the different kind of listening methods, you may tag it with
ListenerInterface. This
is completely optional but makes your intentions clear to other programmers.
| Modifier and Type | Method and Description |
|---|---|
default void |
onRegister(RegistrationEvent e)
This method is called right after this listener has been registered to a
new
EventProvider. |
default void |
onUnregister(RegistrationEvent e)
This method is called right after this listener has been removed from an
EventProvider. |
default void onRegister(RegistrationEvent e)
EventProvider. Setting the passed Event's handled
attribute to true will have no effect.
Note: The default implementation does nothing.
e - This event object holds the new parent EventProvider and the
class for which this listener has been registered.default void onUnregister(RegistrationEvent e)
EventProvider. If this method throws an unchecked exception, it
will be covered by the former EventProvider's ExceptionCallback.
Note: The default implementation does nothing.
e - This event object holds the former parent EventProvider and the
class for which this listener has been unregistered.Copyright © 2014–2015. All rights reserved.