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