使用 RXJava 防止快速点击 [英] Preventing rapid clicks with RXJava

查看:77
本文介绍了使用 RXJava 防止快速点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 android 应用程序并使用 rxjava 来处理用户输入事件.基本上我想要做的是,在单击按钮时发出,然后在一段时间内(例如一两秒钟)丢弃后续的发射,主要是为了防止必须处理多次单击按钮.

I am writing an android app and using rxjava to handle user input events. Basically what I want to do is, emit when a button is clicked, and then drop subsequent emissions for some period of time afterwards (like a second or two), essentially to prevent having to process multiple clicks of the button.

推荐答案

我认为 throttleFirst 是你想要的:https://github.com/Netflix/RxJava/wiki/Filtering-Observables#wiki-throttlefirst

I think throttleFirst is what you want: https://github.com/Netflix/RxJava/wiki/Filtering-Observables#wiki-throttlefirst

这篇关于使用 RXJava 防止快速点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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