This is a alpha version of RxSwift 2.0.
New version of the language helped us to improve a lot of things and this is a short summary of changes.
- Removes deprecated APIs
- Adds
ObservableType
- Moved from using
>-
operator to protocol extensions.
- Adds support for Swift 2.0 error handling
try
/do
/catch
You can now just write
API.fetchData(URL)
.map { rawData in
if invalidData(rawData) {
throw myParsingError
}
...
return parsedData
}
- RxCocoa introduces
bindTo
extensions
combineLatest(firstName.rx_text, lastName.rx_text) { $0 + " " + $1 }
.map { "Greeting \($0)" }
.bindTo(greetingLabel.rx_text)
... works for UITableView
/UICollectionView
too
viewModel.rows
.bindTo(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell")) { (_, viewModel, cell: WikipediaSearchCell) in
cell.viewModel = viewModel
}
.addDisposableTo(disposeBag)
- Adds new operators (array version of
zip
, array version ofcombineLatest
, ...) - Renames
catch
tocatchError
- Change from
disposeBag.addDisposable
todisposable.addDisposableTo
- Deprecates
aggregate
in favor ofreduce
- Deprecates
variable
in favor ofshareReplay(1)
(to be consistent with RxJS version)
Check out Migration guide to RxSwift 2.0