Kotlin Android反跳 [英] Kotlin Android debounce

查看:55
本文介绍了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天全站免登陆