Created
April 5, 2016 13:34
-
-
Save jamiepinkham/cccbcb8c12bfa705c76137b7a086b7fe to your computer and use it in GitHub Desktop.
This file contains 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
struct Result { | |
let text: String | |
let someOtherThing: String | |
} | |
struct Fetcher { | |
static func performQuery(query: String) -> Observable<[Result]> { | |
//returns an observable that hits the network, whose dispose action is to cancel the network request | |
} | |
} | |
class ViewController: UIViewController { | |
weak var textField: UITextField! | |
override func viewDidLoad() { | |
let o: Observable<[String]> = | |
textField.rx_text | |
.throttle(0.3) | |
.distinctUntilChanged() | |
.flatMapLatest { query in | |
Fetcher.performQuery(query) | |
}.map { $0.map { $0.text } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment