I am trying to detect if a observable(my case button.rx.tap) has not emitted any value for say like 3 seconds. If yes, I would like to update the user interface. Here is my attempt so far:
Observable<Int>.interval(3, scheduler: MainScheduler.instance)
.takeUntil(button.rx.tap) // I know take until will stop the timer sequence
.subscribe({ event in
print(event)
UIView.animate(withDuration: 0.4, animations: {
if let number = event.element {
let scale: CGFloat = number % 2 == 0 ? 1.5 : 1.0
self.button.transform = CGAffineTransform(scaleX: scale, y: scale)
}
})
})
.addDisposableTo(disposeBag)
My goal is to animate the view whenever the button is not tapped for three seconds. I have tried scan, distinctUntilChanged and debounce but most combining operators I have encountered will emit items only when an item is emitted by a observable. Any help is much appreciated.