I am trying to play a simple timer using RxSwift.
I only have a pause / play button that works to pause and resume.
gameTimer = Observable<NSInteger>.interval(1, scheduler: MainScheduler.instance) .subscribeNext({ sec -> Void in print("\(sec) s") }).addDisposableTo(disposeBag!) pauseResumeButton.rx_tap .map{ !self.isRunning.value } .startWith(true) .bindTo( isRunning ) .addDisposableTo(disposeBag!)
isRunning is a < Bool > variable, obviously. I can stop the timer settings of disposeBag = nil but I can not pause it .... tried to filter events, but obviously the score continues to grow ...
Can someone help me? Thanks!
source share