Class Event<EVENT_DATA>
java.lang.Object
org.teamapps.event.Event<EVENT_DATA>
- Type Parameters:
EVENT_DATA- The type of data this event fires.
- Direct Known Subclasses:
DecoupledEvent
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 listenerL is added while the thread is bound to a SessionContext A (so while SessionContext.currentOrNull() is not null),
L's execution will be bound to 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 -
Method Summary
Modifier and TypeMethodDescriptionaddListener(Runnable listener) addListener(Runnable listener, boolean bindToSessionContext) addListener(Consumer<EVENT_DATA> listener) addListener(Consumer<EVENT_DATA> listener, boolean bindToSessionContext) addListener(SelfDisposingEventListener<EVENT_DATA> listener) addListener(SelfDisposingEventListener<EVENT_DATA> listener, boolean bindToSessionContext) <T> Event<T> converted(Function<EVENT_DATA, T> converter) voidfire()voidfire(EVENT_DATA eventData) voidfireIfChanged(EVENT_DATA eventData) voidfireIgnoringExceptions(EVENT_DATA eventData) protected voidinvokeListener(EVENT_DATA eventData, Consumer<EVENT_DATA> listener) May get overridden.voidremoveListener(Runnable listener) Deprecated.voidremoveListener(Consumer<EVENT_DATA> listener) Deprecated.Use theDisposablereturned byaddListener(Consumer)instead!
-
Constructor Details
-
Event
public Event()
-
-
Method Details
-
addListener
-
addListener
-
addListener
-
addListener
public Disposable addListener(SelfDisposingEventListener<EVENT_DATA> listener, boolean bindToSessionContext) -
addListener
-
addListener
-
removeListener
Deprecated.Use theDisposablereturned byaddListener(Runnable)instead! -
removeListener
Deprecated.Use theDisposablereturned byaddListener(Consumer)instead! -
fire
-
fireIgnoringExceptions
-
invokeListener
May get overridden. -
fire
public void fire() -
fireIfChanged
-
converted
-
Disposablereturned byaddListener(Runnable)instead!