Updated on 2026-08-14
This commit is contained in:
parent
d0d9fcfef8
commit
d772beda45
11 changed files with 90 additions and 41 deletions
|
|
@ -25,11 +25,12 @@ class Debouncer {
|
|||
coroutineScope: CoroutineScope,
|
||||
waitMs: Long = 300L,
|
||||
context: CoroutineContext = EmptyCoroutineContext,
|
||||
forceUpdate: Boolean = false,
|
||||
destinationFunction: suspend () -> Unit,
|
||||
) {
|
||||
debounceJob?.cancel()
|
||||
debounceJob = coroutineScope.launch(context) {
|
||||
delay(waitMs)
|
||||
if (!forceUpdate) delay(waitMs)
|
||||
destinationFunction.invoke()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue