【发布时间】:2019-09-05 20:47:52
【问题描述】:
在 RxJava1 中,您可以通过这种方式创建去抖动器
RxSearchView.queryTextChanges(searchView)
.debounce(1, TimeUnit.SECONDS) // stream will go down after 1 second inactivity of user
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<CharSequence>() {
@Override
public void accept(@NonNull CharSequence charSequence) throws Exception {
// perform necessary operation with `charSequence`
}
});
根据Wait until the user stops typing before executing a heavy search in searchview
但我不知道如何在 RxJava2 中创建它
【问题讨论】:
-
RxJava 2 使用
io.reactivex.Observable作为类型,io.reactivex.functions.Consumer用于subscribe重载。请使用queryTextChanges检查您的类型是否正确。