https://kotlinlang.org logo
Title
i

igor.wojda

08/21/2018, 1:23 PM
Hey What is the best way to deal with button clicks debouncing and Kotlin Android Extensions? Is there any simple way to debounce clicks for whole app?
l

louiscad

08/21/2018, 1:31 PM
There's no "best" way, there's multiple approaches. I personally has not needed to debounce button clicks, because for one shot actions, I just disable the button entirely until some processing is done, if the button ever needs to be re-enabled. However, if I needed to do it, I'd probably use #coroutines to do it, maybe using a for loop,
delay(...)
and this
awaitOneClick()
extension function I wrote: https://gist.github.com/LouisCAD/c91f971c9771036f6af14fde3527e42a
i

igor.wojda

08/22/2018, 1:10 PM
Grey area s usual 😉 thx @louiscad