RxTimer
RxTimer provides an easy to use RxSwift binding for NSTimer.
Usage
1 second default timer
NSTimer.rx_timer
.subscribeNext { _ in
print("timer triggered")
}
.addDisposableTo(disposeBag)
Any number of seconds
NSTimer.rx_timer(10)
.subscribeNext { _ in
print("timer triggered")
}
.addDisposableTo(disposeBag)
Skip first event to ignore trigger upon subscribing
NSTimer.rx_timer(10)
.skip(1)
.subscribeNext { _ in
print("timer triggered")
}
.addDisposableTo(disposeBag)
Take(n) to cancel the timer after n number of calls
NSTimer.rx_timer(10)
.take(10)
.subscribeNext { _ in
print("timer triggered")
}
.addDisposableTo(disposeBag)
Installing
CocoaPods
pod 'RxTimer'
And that'll be
License
MIT License.