CSThrottler
class CSThrottler<T>(parent: CSHasRegistrations, dispatcher: CoroutineContext = Main, action: suspend (T) -> Unit, after: Duration = ZERO) : Function1<T, Unit>
A thread-safe, coroutine-based Throttler.
It limits the execution frequency of the action to the duration specified in after. If multiple events occur during the after window, only the latest one is processed (Conflation strategy).
Parameters
parent
A scope wrapper (CSHasRegistrations) that controls the lifecycle of this throttler.
dispatcher
The CoroutineContext where the action will run (default: Main).
action
The actual work to perform (suspend function).
after
The "cooldown" or "grouping" window duration.
Type Parameters
T
The type of data passed to the action.
Constructors
Link copied to clipboard
constructor(parent: CSHasRegistrations, dispatcher: CoroutineContext = Main, action: suspend (T) -> Unit, after: Duration = ZERO)