- Type Parameters:
T
- the type of data propagated with this event
- All Superinterfaces:
Consumer<T>
,EventObserver<T>
,Runnable
An event class. Listeners are notified in the order they were added.
Event<Boolean> event = Event.event(); EventObserver<Boolean> observer = event.observer(); observer.addListener(this::doSomething); observer.addDataListener(this::onBoolean); event.accept(true);A factory class for
Event
instances.-
Method Summary
Modifier and TypeMethodDescriptionvoid
Triggers this event.static <T> Consumer<T>
dataListener
(Runnable listener) static <T> Event<T>
event()
Creates a newEvent
.static <T> Runnable
Creates aRunnable
causing thelistener
sConsumer.accept(Object)
to be called with a null argument on each occurrence.observer()
void
run()
Triggers this event.Methods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, addWeakDataListener, addWeakListener, removeDataListener, removeListener, removeWeakDataListener, removeWeakListener
-
Method Details
-
run
void run()Triggers this event. -
accept
Triggers this event. -
observer
EventObserver<T> observer()- Returns:
- an observer notified each time this event occurs
-
event
Creates a newEvent
.- Type Parameters:
T
- the type of data propagated to listeners on event occurrence- Returns:
- a new Event
-
listener
Creates aRunnable
causing thelistener
sConsumer.accept(Object)
to be called with a null argument on each occurrence. -
dataListener
Creates aConsumer
causing thelistener
sRunnable.run()
to be called on each occurrence. Note that any event data will get discarded along the way.
-