Skip to content

Instantly share code, notes, and snippets.

@bricklife
Created June 10, 2016 02:49
Show Gist options
  • Save bricklife/896bd72ba72123faa26b1056135c3638 to your computer and use it in GitHub Desktop.
Save bricklife/896bd72ba72123faa26b1056135c3638 to your computer and use it in GitHub Desktop.
ReactiveCocoaにもTestSchedulerがあったけど、RxSwiftのと比べると必要最低限な実装という印象。このコードも期待通りの動きをしない #CodePiece
import Result
import ReactiveCocoa
let scheduler = TestScheduler(startDate: NSDate(timeIntervalSince1970: 0))
timer(10, onScheduler: scheduler)
.start { _ in print(scheduler.currentDate) }
scheduler.advanceByInterval(60)
/*
1970-01-01 00:01:00 +0000
1970-01-01 00:01:00 +0000
1970-01-01 00:01:00 +0000
1970-01-01 00:01:00 +0000
1970-01-01 00:01:00 +0000
1970-01-01 00:01:00 +0000
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment