I am new in coroutines
. So now I look how to use coroutines instead of handlers
The Handler code:
fun Handler.repostDelayed(func: Runnable, delay: Long) {
removeCallbacksAndMessages(null)
postDelayed(func, delay)
}
Analog in Coroutines
inline fun AppCompatActivity.repostDelayed(crossinline func: () -> Unit, delay: Long) {
lifecycleScope.cancel()
lifecycleScope.launch {
delay(delay) //debounce timeOut
func()
}
}
But it does not work. Could You fix my expression for Coroutines, please?