Package com.vaadin.client.flow.binding
Class Debouncer
java.lang.Object
com.vaadin.client.flow.binding.Debouncer
Manages debouncing of events. Use
getOrCreate(Node, String, double)
to either create a new instance or get an existing instance that currently
tracks a sequence of similar events.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionflushAll()Flushes all pending changes.static DebouncergetOrCreate(elemental.dom.Node element, String identifier, double debounce) Gets an existing debouncer or creates a new one associated with the given DOM node, identifier and debounce timeout.booleanInforms this debouncer that an event has occurred.
-
Method Details
-
trigger
public boolean trigger(JsSet<String> phases, Consumer<String> command, JsMap<String, Runnable> commands) Informs this debouncer that an event has occurred.- Parameters:
phases- a set of strings identifying the phases for which the triggered event should be considered.command- a consumer that will may be asynchronously invoked with a phase code if an associated phase is triggeredcommands- individual commands executed just before the given send command- Returns:
trueif the event should be processed as-is without delaying
-
getOrCreate
Gets an existing debouncer or creates a new one associated with the given DOM node, identifier and debounce timeout.- Parameters:
element- the DOM node to which this debouncer is boundidentifier- a unique identifier string in the scope of the provided elementdebounce- the debounce timeout- Returns:
- a debouncer instance
-
flushAll
Flushes all pending changes. After command execution, Debouncer idle timers are rescheduled.- Returns:
- the list command executed during flush operation.
-