Bindings

suggest change
Observable.combineLatest(firstName.rx_text, lastName.rx_text) { $0 + " " + $1 }
.map { "Greetings, \($0)" }
.bindTo(greetingLabel.rx_text)

combineLatest emits whenever either Observable emits, pairing the latest value from each. Here the two UITextField values are joined into "Greetings, \($0)" and bound to a UILabel.

You can bind rows to a UITableView or UICollectionView the same way:

viewModel
.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in
    cell.title = viewModel.title
    cell.url = viewModel.url
}
.addDisposableTo(disposeBag)

That is an Rx wrapper around cellForRowAt. Rx also supplies numberOfRowsInSection, which a normal data source must implement, so you do not write it here.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents