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 a SessionContext 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 A is destroyed (and thereby fires its SessionContext.onDestroyed event), the listener is automatically detached from this event.
You can prevent a listener from being bound to the current SessionContext, by using one of the addListener(..., boolean bindToSessionContext) methods.
  • Constructor Summary

    Constructors 
    Constructor Description
    Event()  
  • Method Summary

    Modifier and Type Method Description
    void addListener​(java.lang.Runnable listener)  
    void addListener​(java.lang.Runnable listener, boolean bindToSessionContext)  
    void addListener​(java.util.function.Consumer<EVENT_DATA> listener)  
    void addListener​(java.util.function.Consumer<EVENT_DATA> listener, boolean bindToSessionContext)  
    <T> Event<T> converted​(java.util.function.Function<EVENT_DATA,​T> converter)  
    void fire()  
    void fire​(EVENT_DATA eventData)  
    void fireIfChanged​(EVENT_DATA eventData)  
    void removeListener​(java.lang.Runnable listener)  
    void removeListener​(java.util.function.Consumer<EVENT_DATA> listener)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait