Swift Language RxSwift Bindings


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

Using the combineLatest operator every time an item is emitted by either of two Observables, combine the latest item emitted by each Observable. So in this way we combine the result of the two UITextField's creating a new message with the text "Greetings, \($0)" using string interpolation to later bind to the text of a UILabel.

We can bind data to any UITableView and UICollectionView in an very easy way:

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

That’s an Rx wrapper around the cellForRowAtIndexPath data source method. And also Rx takes care of the implementation of the numberOfRowsAtIndexPath, which is a required method in a traditional sense, but you don’t have to implement it here, it’s taken care of.