Search code examples
androidkotlinkotlin-android-extensionskotlin-extensionkotlinx.coroutines

Kotlin Android debounce


Is there any fancy way to implement debounce logic with Kotlin Android?

I'm not using Rx in project.

There is a way in Java, but it is too big as for me here.


Solution

  • You can use kotlin coroutines to achieve that. Here is an example.

    Be aware that coroutines are experimental at kotlin 1.1+ and it may be changed in upcoming kotlin versions.

    UPDATE

    Since Kotlin 1.3 release, coroutines are now stable.