Package com.vaadin.client.flow.reactive
Class ReactiveEventRouter<L,E extends ReactiveValueChangeEvent>
- java.lang.Object
-
- com.vaadin.client.flow.reactive.ReactiveEventRouter<L,E>
-
- Type Parameters:
L- the listener type of this routerE- the reactive event type of this router
public abstract class ReactiveEventRouter<L,E extends ReactiveValueChangeEvent> extends Object
Event router providing integration with reactive features inReactiveandComputation. 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 usingReactive.addEventCollector(ReactiveValueChangeListener).- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Constructor Summary
Constructors Constructor Description ReactiveEventRouter(ReactiveValue reactiveValue)Creates a new event router for a reactive value.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description elemental.events.EventRemoveraddListener(L listener)Adds a listener to this event router.elemental.events.EventRemoveraddReactiveListener(ReactiveValueChangeListener reactiveValueChangeListener)Adds a generic reactive change listener to this router.protected abstract voiddispatchEvent(L listener, E event)Callback for dispatching an event to a listener.voidfireEvent(E event)Fires an event to all listeners added to this router usingaddListener(Object)oraddReactiveListener(ReactiveValueChangeListener)as well as all global event collectors added usingReactive.addEventCollector(ReactiveValueChangeListener).ReactiveValuegetReactiveValue()Gets the reactive value for which this router fires event.voidregisterRead()Registers access to the data for which this event router fires event.protected abstract Lwrap(ReactiveValueChangeListener reactiveValueChangeListener)Callback for wrapping a generic reactive change listener to an instance of the listener type natively supported by this event router.
-
-
-
Constructor Detail
-
ReactiveEventRouter
public ReactiveEventRouter(ReactiveValue reactiveValue)
Creates a new event router for a reactive value.- Parameters:
reactiveValue- the reactive value, notnull
-
-
Method Detail
-
addListener
public elemental.events.EventRemover addListener(L listener)
Adds a listener to this event router.- Parameters:
listener- the listener to add, notnull- 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, notnull- Returns:
- an event remover that can be used for removing the added listener
-
fireEvent
public void fireEvent(E event)
Fires an event to all listeners added to this router usingaddListener(Object)oraddReactiveListener(ReactiveValueChangeListener)as well as all global event collectors added usingReactive.addEventCollector(ReactiveValueChangeListener).- Parameters:
event- the event to fire
-
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
-
-