Package org.teamapps.event
Class Event<EVENT_DATA>
java.lang.Object
org.teamapps.event.Event<EVENT_DATA>
- Type Parameters:
EVENT_DATA- The type of data this event fires.
public class Event<EVENT_DATA>
extends java.lang.Object
Represents an event that can get fired.
Listeners can be added to this event using the various addListener(...) methods.
SessionContext-bound Event Listeners
Note that if a listener is added while the thread is bound to aSessionContext A (so while SessionContext.currentOrNull() is not null),
the event will be bound to this SessionContext (A) by default, i.e.:
- When this event fires, the SessionContext-bound listener will get invoked bound to the SessionContext
A, regardless of the SessionContext (or the lack of it) the event was fired in. - When the SessionContext
Ais destroyed (and thereby fires itsSessionContext.onDestroyedevent), the listener is automatically detached from this event.
addListener(..., boolean bindToSessionContext) methods.-
Constructor Summary
Constructors Constructor Description Event() -
Method Summary
Modifier and Type Method Description voidaddListener(java.lang.Runnable listener)voidaddListener(java.lang.Runnable listener, boolean bindToSessionContext)voidaddListener(java.util.function.Consumer<EVENT_DATA> listener)voidaddListener(java.util.function.Consumer<EVENT_DATA> listener, boolean bindToSessionContext)<T> Event<T>converted(java.util.function.Function<EVENT_DATA,T> converter)voidfire()voidfire(EVENT_DATA eventData)voidfireIfChanged(EVENT_DATA eventData)voidremoveListener(java.lang.Runnable listener)voidremoveListener(java.util.function.Consumer<EVENT_DATA> listener)
-
Constructor Details
-
Event
public Event()
-
-
Method Details
-
addListener
-
addListener
public void addListener(java.util.function.Consumer<EVENT_DATA> listener, boolean bindToSessionContext) -
addListener
public void addListener(java.lang.Runnable listener) -
addListener
public void addListener(java.lang.Runnable listener, boolean bindToSessionContext) -
removeListener
public void removeListener(java.lang.Runnable listener) -
removeListener
-
fire
-
fire
public void fire() -
fireIfChanged
-
converted
-