Package 

Class Debouncer

  • All Implemented Interfaces:

    
    public final class Debouncer
    
                        

    Utility class for debouncing high frequency events.

    submitting a new piece of work to run within the debounce window will cancel the previously submitted pending work.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Debouncer(Long debounceMs, CoroutineScope scope)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit submit(Function0<Unit> work) Cancels the previous work and launches a new coroutine containing the new work.
      final Unit submitSuspendable(SuspendFunction0<Unit> work) Cancels the previous work and launches a new coroutine containing the new suspendable work.
      final Unit cancelLastDebounce() Cancels the current work without shutting down the Coroutine scope.
      final Unit shutdown() Cleans up any pending work.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Debouncer

        Debouncer(Long debounceMs, CoroutineScope scope)
    • Method Detail

      • submit

         final Unit submit(Function0<Unit> work)

        Cancels the previous work and launches a new coroutine containing the new work.

      • cancelLastDebounce

         final Unit cancelLastDebounce()

        Cancels the current work without shutting down the Coroutine scope.

      • shutdown

         final Unit shutdown()

        Cleans up any pending work.

        Note that a shut down Debouncer will never execute work again.