Throttler
class Throttler(timeoutMillis: Int, scope: CoroutineScope = CoroutineScope(Dispatchers.Default + Job()))
A coroutine-based throttler
val throttler = Throttler(200)
for (i in 0..100) {
delay(100)
throttler.emit { println("Hello!") }
}
Content copied to clipboard
Parameters
timeoutMillis
The minimum time interval to wait before running the provided action
scope
The coroutine scope to run the action in