Class Event<EVENT_DATA>

  • Type Parameters:
    EVENT_DATA - The type of data this event fires.
    Direct Known Subclasses:
    DecoupledEvent

    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 Detail

      • Event

        public Event()
    • Method Detail

      • addListener

        public void addListener​(java.util.function.Consumer<EVENT_DATA> listener)
      • 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

        public void removeListener​(java.util.function.Consumer<EVENT_DATA> listener)
      • fire

        public void fire​(EVENT_DATA eventData)
      • fireIgnoringExceptions

        public void fireIgnoringExceptions​(EVENT_DATA eventData)
      • invokeListener

        protected void invokeListener​(EVENT_DATA eventData,
                                      java.util.function.Consumer<EVENT_DATA> listener)
        May get overridden.
      • fire

        public void fire()
      • fireIfChanged

        public void fireIfChanged​(EVENT_DATA eventData)
      • converted

        public <T> Event<T> converted​(java.util.function.Function<EVENT_DATA,​T> converter)