Debouncer

class Debouncer(debounceMs: Long, scope: CoroutineScope = CoroutineScope(DispatcherProvider.Main))

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.

Constructors

Link copied to clipboard
constructor(debounceMs: Long, scope: CoroutineScope = CoroutineScope(DispatcherProvider.Main))

Functions

Link copied to clipboard

Cancels the current work without shutting down the Coroutine scope.

Link copied to clipboard
fun shutdown()

Cleans up any pending work.

Link copied to clipboard
fun submit(work: () -> Unit)

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

Link copied to clipboard
fun submitSuspendable(work: suspend () -> Unit)

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