Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun EditText.debounce(delay: Long, action: (Editable?) -> Unit) {
doAfterTextChanged { text ->
var counter = getTag(id) as? Int ?: 0
handler.removeCallbacksAndMessages(counter)
handler.postDelayed(delay, ++counter) { action(text) }
setTag(id, counter)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment