-
- Type Parameters:
T
- the type of data propagated with this event
- All Superinterfaces:
EventDataListener<T>
,EventListener
,EventObserver<T>
public interface Event<T> extends EventListener, EventDataListener<T>, EventObserver<T>
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.onEvent(true);
A factory class forEvent
instances.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T> EventDataListener<T>
dataListener(EventListener listener)
Creates aEventDataListener
causing thelistener
sEventListener.onEvent()
to be called on each occurrence.static <T> Event<T>
event()
Creates a newEvent
.static <T> EventListener
listener(EventDataListener<T> listener)
Creates aEventListener
causing thelistener
sEventDataListener.onEvent(Object)
to be called with a null argument on each occurrence.EventObserver<T>
observer()
-
Methods inherited from interface is.codion.common.event.EventDataListener
onEvent
-
Methods inherited from interface is.codion.common.event.EventListener
onEvent
-
Methods inherited from interface is.codion.common.event.EventObserver
addDataListener, addListener, removeDataListener, removeListener
-
-
-
-
Method Detail
-
observer
EventObserver<T> observer()
- Returns:
- an observer notified each time this event occurs
-
event
static <T> Event<T> event()
Creates a newEvent
.- Type Parameters:
T
- the type of data propagated to listeners on event occurrence- Returns:
- a new Event
-
listener
static <T> EventListener listener(EventDataListener<T> listener)
Creates aEventListener
causing thelistener
sEventDataListener.onEvent(Object)
to be called with a null argument on each occurrence.- Type Parameters:
T
- the value type- Parameters:
listener
- the data listener- Returns:
- a
EventListener
causing the givenEventDataListener
to be called with null data on each occurrence
-
dataListener
static <T> EventDataListener<T> dataListener(EventListener listener)
Creates aEventDataListener
causing thelistener
sEventListener.onEvent()
to be called on each occurrence. Note that any event data will get discarded along the way.- Type Parameters:
T
- the type of data propagated to listeners on event occurrence- Parameters:
listener
- the listener- Returns:
- a
EventDataListener
causing the givenEventListener
to be called on each occurrence
-
-