-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Description
I used throttleFirst operator for prevening duplicated click event like below
RxView.clicks(v).throttleFirst(500, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
It works well in general case. But if user changed system time as past after click view, thrrottleFist doesn't emit item. (In the android, user can change system time using settings application.)
Because, OperatorThrottleFirst's below routine.
@Override
public Subscriber<? super T> call(final Subscriber<? super T> subscriber) {
return new Subscriber<T>(subscriber) {
private long lastOnNext = -1;
// ...
@Override
public void onNext(T v) {
long now = scheduler.now();
if (lastOnNext == -1 || now - lastOnNext >= timeInMilliseconds) {
lastOnNext = now;
subscriber.onNext(v);
}
}
I think (now - lastOnNext) become negative value, item should be emitted too.