Kotlin Android 去抖 [英] Kotlin Android debounce

查看:29
本文介绍了Kotlin Android 去抖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有什么奇特的方法可以用 Kotlin Android 实现 debounce 逻辑?

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

我没有在项目中使用 Rx.

I'm not using Rx in project.

Java 中有一种方法,但它对我来说太大了.

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

推荐答案

您可以使用 kotlin 协程 来实现这一点.这是一个例子.

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

请注意,协程在 kotlin 1.1+ 上进行实验,可能会在即将推出的 kotlin 版本中进行更改.

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

自从 Kotlin 1.3 发布以来,协程现在稳定.

Since Kotlin 1.3 release, coroutines are now stable.

这篇关于Kotlin Android 去抖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆