Created
February 12, 2017 05:39
-
-
Save bleeckerj/9c9b42e7643a291aa98a1cbe975d074f to your computer and use it in GitHub Desktop.
Driving a sequence with an array that's emitted with an interval period.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import PlaygroundSupport | |
| PlaygroundPage.current.needsIndefiniteExecution = true | |
| import UIKit | |
| import RxSwift | |
| import RxCocoa | |
| import RxOptional | |
| import Foundation | |
| let letters = ["A","B","C","D","E","F"] | |
| let intDriver = Observable<Int>.interval(0.75, scheduler: MainScheduler.instance) | |
| .asDriver(onErrorJustReturn: -1) | |
| .map { $0 } | |
| //.filter { $0 < 7 } | |
| _ = intDriver.drive(onNext: { | |
| x in print(letters[x % letters.count]) | |
| }) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helpful for delaying the moving of data particularly in Bluetooth!