| Modifier and Type | Method and Description |
|---|---|
static <T extends IEvent> |
addListener(Class<T> eventClass,
Consumer<T> callback)
Adds a callback function that is to be executed when a specified event is
dispatched.
|
static <R,T extends ISynchronousEvent<R>> |
addSynchronousListener(Class<T> eventClass,
Function<T,R> callback)
Adds a callback function that executes and returns a value when a
specified synchronous event is dispatched.
|
static <R,T extends ISynchronousEvent<R>> |
addSynchronousListener(Class<T> eventClass,
Supplier<R> callback)
Adds a callback function that executes and returns a value when a
specified synchronous event is dispatched.
|
static boolean |
hasAsynchronousEventListeners()
Checks if there are registered event listeners.
|
static boolean |
hasSynchronousEventListeners()
Checks if there are registered synchronous event listeners.
|
static <T extends IEvent> |
removeAllListeners(Class<T> eventClass)
Removes all event listeners of a specified event.
|
static <T extends IEvent> |
removeListener(Class<T> eventClass,
Consumer<T> callback)
Removes a callback function for a specified event.
|
static <T extends ISynchronousEvent<?>> |
removeSynchronousListener(Class<T> eventClass)
Removes the callback function of a synchronous event.
|
static void |
reset()
Removes all listeners and clears the queue.
|
static <T extends IEvent> |
sendEvent(T event)
Dispatches a specified asynchronous event by adding it to a queue.
|
static <R,T extends ISynchronousEvent<R>> |
sendSynchronousEvent(T event)
Dispatches a synchronous event that executes a unique callback function
and returns its calculated value.
|
public static <T extends IEvent> void addListener(Class<T> eventClass, Consumer<T> callback)
T - the type of the eventeventClass - the class of the eventcallback - the callback function that is executed when the event is
dispatchedpublic static <T extends IEvent> void removeListener(Class<T> eventClass, Consumer<T> callback)
T - the type of the eventeventClass - the class of the eventcallback - the callback function that is to be removed from the
eventpublic static <T extends IEvent> void removeAllListeners(Class<T> eventClass)
T - the type of the eventeventClass - the class of the eventpublic static void reset()
public static <T extends IEvent> void sendEvent(T event)
T - the type of the dispatched eventevent - the event that is dispatchedpublic static <R,T extends ISynchronousEvent<R>> void addSynchronousListener(Class<T> eventClass, Function<T,R> callback)
T - the type of the synchronous eventR - the type of the return value of the callback functioneventClass - the class of the synchronous eventcallback - a callback function that requires the event as a parameter
and returns a specified value when the event is dispatchedpublic static <R,T extends ISynchronousEvent<R>> void addSynchronousListener(Class<T> eventClass, Supplier<R> callback)
T - the type of the synchronous eventR - the type of the return value of the callback functioneventClass - the class of the synchronous eventcallback - a callback function that expects no parameters and returns when
the event is dispatchedpublic static <T extends ISynchronousEvent<?>> void removeSynchronousListener(Class<T> eventClass)
T - the type of the synchronous eventeventClass - the class of the synchronous eventpublic static <R,T extends ISynchronousEvent<R>> R sendSynchronousEvent(T event)
T - the type of the synchronous eventR - the type of the return value of the callback functionevent - a synchronous eventpublic static boolean hasAsynchronousEventListeners()
public static boolean hasSynchronousEventListeners()
Copyright © 2017–2019. All rights reserved.