Class Debouncer


  • public class Debouncer
    extends Object
    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 Detail

      • trigger

        public boolean trigger​(JsSet<String> phases,
                               Consumer<String> command)
        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 triggered
        Returns:
        true if the event should be processed as-is without delaying
      • getOrCreate

        public static Debouncer getOrCreate​(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.
        Parameters:
        element - the DOM node to which this debouncer is bound
        identifier - a unique identifier string in the scope of the provided element
        debounce - the debounce timeout
        Returns:
        a debouncer instance
      • flushAll

        public static List<Consumer<String>> flushAll()
        Flushes all pending changes. After command execution, Debouncer idle timers are rescheduled.
        Returns:
        the list command executed during flush operation.