rxBindings - 在去抖动点击事件时如何知道消费者类型应该是什么?
rxBindings - How to know what consumer type should be when debouncing click events?
使用 rxBindings 我试图减慢点击事件的速度,但我想知道需要什么参数。
例如,这是我在图像视图上进行的调用。所以 ImageView v;
RxView.clicks(v)
.throttleFirst(400, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.subscribe(new Consumer<Object>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Object v) throws Exception {
showBottomSheet(getAdapterPosition());
}
});
but im im not sure what the parameter in accept should be ?
I was expecting i would get the view here but when i try changing the type to View i get an error of no such method.
如果您查看使用 RxView.clicks()
生成的 Observable
的 source code,您会看到当点击发生时,会触发以下代码:
observer.onNext(Notification.INSTANCE);
在库中定义为:
public enum Notification {
INSTANCE
}
这只是表示事件发生的一种方便方式,它不携带任何额外信息。
使用 rxBindings 我试图减慢点击事件的速度,但我想知道需要什么参数。
例如,这是我在图像视图上进行的调用。所以 ImageView v;
RxView.clicks(v)
.throttleFirst(400, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
.subscribe(new Consumer<Object>() {
@Override
public void accept(@io.reactivex.annotations.NonNull Object v) throws Exception {
showBottomSheet(getAdapterPosition());
}
});
but im im not sure what the parameter in accept should be ?
I was expecting i would get the view here but when i try changing the type to View i get an error of no such method.
如果您查看使用 RxView.clicks()
生成的 Observable
的 source code,您会看到当点击发生时,会触发以下代码:
observer.onNext(Notification.INSTANCE);
在库中定义为:
public enum Notification {
INSTANCE
}
这只是表示事件发生的一种方便方式,它不携带任何额外信息。