CSDebouncer

class CSDebouncer(parent: CSHasRegistrations, scope: CoroutineScope, dispatcher: CoroutineContext = Main, action: suspend () -> Unit, after: Duration = 1.milliseconds) : CSFunc

A debouncer class to delay action execution until a period of inactivity.

The purpose of a debouncer is to consolidate multiple quick, successive calls into a single action execution after a specified delay (the "debounce delay"). This is useful in scenarios such as handling UI events (button clicks, text input) to avoid invoking costly operations repeatedly.

In this implementation, the debouncer uses a MutableSharedFlow to collect invocations and schedule the action using coroutines. The action will be executed only when no new invocations are received for the specified delay.

Constructors

Link copied to clipboard
constructor(parent: CSHasRegistrations, scope: CoroutineScope, dispatcher: CoroutineContext = Main, action: suspend () -> Unit, after: Duration = 1.milliseconds)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open operator override fun invoke()