Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
StopWhenTap
import UIKit
import RxSwift
import RxCocoa
import NSObject_Rx
class ViewController: UIViewController {
@IBOutlet var stop: UIButton!
let timer = Observable<Int>.interval(1, scheduler: MainScheduler.instance)
override func viewDidLoad() {
super.viewDidLoad()
timer
.takeUntil(stop.rx_tap)
.subscribe { event in
switch event {
case .Next(let value):
print(value)
case .Error(let error):
print(error)
case .Completed:
print("Completed")
}
}
.addDisposableTo(rx_disposeBag)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment