Skip to content

Instantly share code, notes, and snippets.

@bleeckerj
Created February 12, 2017 05:39
Show Gist options
  • Select an option

  • Save bleeckerj/9c9b42e7643a291aa98a1cbe975d074f to your computer and use it in GitHub Desktop.

Select an option

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.
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])
})
@bleeckerj

Copy link
Copy Markdown
Author

Helpful for delaying the moving of data particularly in Bluetooth!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment