Skip to content

bmoliveira/RxTimer

Repository files navigation

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'

Carthage

Cartfile

github "bmoliveira/RxTimer" ~> 1.3

And that'll be 👌

License

MIT License.