Reputation: 1372
I'm relatively new to RxSwift. I have an Observable and want to bind it to a UITableView. All examples and solutions I found so far use Observables<[Item]> to bind it to a TableView - but I don't have the result of type Array.
How would I convert my Observable to an Observable<[Item]>? Or how would I use the Observable to show the results in a TableView?
Upvotes: 0
Views: 2196
Reputation: 1418
Here you have nice example
let items = Observable.just([
"First Item",
"Second Item",
"Third Item"
])
items
.bindTo(tableView.rx.items) { (tableView, row, element) in
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
cell.textLabel?.text = "\(element) @ row \(row)"
return cell
}
.addDisposableTo(disposeBag)
Upvotes: 1