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
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 Summary
ConstructorsConstructorDescriptionReactiveEventRouter(ReactiveValue reactiveValue) Creates a new event router for a reactive value. -
Method Summary
Modifier and TypeMethodDescriptionelemental.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.voidFires an event to all listeners added to this router usingaddListener(Object)oraddReactiveListener(ReactiveValueChangeListener)as well as all global event collectors added usingReactive.addEventCollector(ReactiveValueChangeListener).Gets the reactive value for which this router fires event.voidRegisters 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 Details
-
ReactiveEventRouter
Creates a new event router for a reactive value.- Parameters:
reactiveValue- the reactive value, notnull
-
-
Method Details
-
addListener
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
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
Gets the reactive value for which this router fires event.- Returns:
- the reactive value
-
wrap
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
Callback for dispatching an event to a listener.- Parameters:
listener- the listener that should receive the eventevent- the event to dispatch
-