Reputation: 47374
I have a button which sends network requests. I want to ignore double taps within this button. I tried .throttle
, but that didn't seem to work. So I'm trying .debounce
- this indeed ignores duplicate taps, but only lets through the last event.
What I want is: On first tap, send a network request, ignore subsequent taps within 0.33 seconds.
Which RXSwift operator would help me put an event through and disable subsequent events within a time window?
let buttonPressObservable = button.rx.tap.asObservable()
buttonPressObservable.debounce(0.33, scheduler: MainScheduler.instance)
.map{/*do stuff*/}
Upvotes: 1
Views: 985
Reputation: 33979
In version 4.2 of the library, throttle
has a parameter latest
that is set to true
by default. If you set that to false, I think it will give you the behavior you want.
Upvotes: 4