Class ReactiveEventRouter<L,​E extends ReactiveValueChangeEvent>

  • Type Parameters:
    L - the listener type of this router
    E - the reactive event type of this router

    public abstract class ReactiveEventRouter<L,​E extends ReactiveValueChangeEvent>
    extends Object
    Event router providing integration with reactive features in Reactive and Computation. Listeners can be added both for a specific event type and for the generic value change. All events are fired to both types of listeners, as well as to event collectors registered using Reactive.addEventCollector(ReactiveValueChangeListener).
    Since:
    1.0
    Author:
    Vaadin Ltd
    • Constructor Detail

      • ReactiveEventRouter

        public ReactiveEventRouter​(ReactiveValue reactiveValue)
        Creates a new event router for a reactive value.
        Parameters:
        reactiveValue - the reactive value, not null
    • Method Detail

      • addListener

        public elemental.events.EventRemover addListener​(L listener)
        Adds a listener to this event router.
        Parameters:
        listener - the listener to add, not null
        Returns:
        an event remover that can be used for removing the added listener
      • addReactiveListener

        public elemental.events.EventRemover addReactiveListener​(ReactiveValueChangeListener reactiveValueChangeListener)
        Adds a generic reactive change listener to this router.
        Parameters:
        reactiveValueChangeListener - the change listener to add, not null
        Returns:
        an event remover that can be used for removing the added listener
      • registerRead

        public void registerRead()
        Registers access to the data for which this event router fires event. This registers the event source of this event router to be set as a dependency of the current computation if there is one.
      • getReactiveValue

        public ReactiveValue getReactiveValue()
        Gets the reactive value for which this router fires event.
        Returns:
        the reactive value
      • wrap

        protected abstract L wrap​(ReactiveValueChangeListener reactiveValueChangeListener)
        Callback for wrapping a generic reactive change listener to an instance of the listener type natively supported by this event router.
        Parameters:
        reactiveValueChangeListener - the reactive change listener
        Returns:
        an event listener wrapping the provided listener
      • dispatchEvent

        protected abstract void dispatchEvent​(L listener,
                                              E event)
        Callback for dispatching an event to a listener.
        Parameters:
        listener - the listener that should receive the event
        event - the event to dispatch