Created
April 5, 2020 10:26
-
-
Save therohansanap/5375f40d5e1c90a66f9ad23746402a6a to your computer and use it in GitHub Desktop.
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
| let results = query.rx.text.asDriver() // This converts a normal sequence into a `Driver` sequence. | |
| .throttle(.milliseconds(300), scheduler: MainScheduler.instance) | |
| .flatMapLatest { query in | |
| fetchAutoCompleteItems(query) | |
| .asDriver(onErrorJustReturn: []) // Builder just needs info about what to return in case of error. | |
| } | |
| results | |
| .map { "\($0.count)" } | |
| .drive(resultCount.rx.text) | |
| .disposed(by: disposeBag) | |
| results | |
| .drive(resultsTableView.rx.items(cellIdentifier: "Cell")) { (_, result, cell) in | |
| cell.textLabel?.text = "\(result)" | |
| } | |
| .disposed(by: disposeBag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment