java.lang.Object
com.inductiveautomation.ignition.designer.mvvm.Debouncer<T>

@ThreadSafe public final class Debouncer<T> extends Object
This class is used to debounce data updates. If you need to know when the debouncer enters the active state, you can provide a callback to be called when the first data update is received after the waitTime has passed.
  • Constructor Details

    • Debouncer

      public Debouncer(long waitTime, Consumer<T> onDataCallback)
      Use this variant of the constructor if you don't need to do anything when the debouncer enters the active state.
      Parameters:
      waitTime - The time to wait before calling the onDataCallback after the last data update.
      onDataCallback - The callback to call when the waitTime has passed without any new data updates.
    • Debouncer

      public Debouncer(Consumer<T> onDataCallback, @Nullable Consumer<T> onStartCallback)
      This creates a debouncer with a standard delay of 250 milliseconds.
      Parameters:
      onDataCallback - The callback to call when the waitTime has passed without any new data updates.
      onStartCallback - The callback to call when the first data update is received after
    • Debouncer

      public Debouncer(long waitTime, Consumer<T> onDataCallback, @Nullable Consumer<T> onStartCallback)
      This in the main constructor. The inactive state happens when there has been no new data updates to this class for the duration of the waitTime. The active state happens when this class receives new data updates.

      Upon entering the active state, the onStartCallback is called if one is provided. It will remain in the active state until the waitTime has passed without any new data updates. When that happens the onDataCallback is called.

      Parameters:
      waitTime - The time to wait before calling the onDataCallback after the last data update.
      onDataCallback - The callback to call when the waitTime has passed without any new data updates.
      onStartCallback - The callback to call when the first data update is received after the waitTime has passed.
  • Method Details

    • update

      public void update(T value)