Great readme commit.

This commit is contained in:
Krunoslav Zaher 2016-04-20 12:08:42 +02:00
parent c7fc68bfc1
commit 0c7ca38cd7
1 changed files with 89 additions and 1 deletions

View File

@ -65,7 +65,95 @@ KVO observing, async operations and streams are all unified under [abstraction o
* Does this exist for Android? [RxJava](https://github.com/ReactiveX/RxJava)
* Where is all of this going, what is the future, what about reactive architectures, how do you design entire apps this way? [Cycle.js](https://github.com/cyclejs/cycle-core) - this is javascript, but [RxJS](https://github.com/Reactive-Extensions/RxJS) is javascript version of Rx.
##### References
## Usage
Define search for GitHub repositories ...
```swift
let searchResults = searchBar.rx_text
.throttle(0.3, scheduler: MainScheduler.instance)
.distinctUntilChanged()
.flatMapLatest { query -> Observable<[Repository]> in
if query.isEmpty {
return Observable.just([])
}
return searchGitHub(query)
.catchErrorJustReturn([])
}
.observeOn(MainScheduler.instance)
```
... bind results to table view
```swift
searchResults
.bindTo(tableView.rx_itemsWithCellIdentifier("Cell")) { (index, repository: Repository, cell) in
cell.textLabel?.text = repository.name
cell.detailTextLabel?.text = repository.url
}
.addDisposableTo(disposeBag)
```
![Example table view](https://raw.githubusercontent.com/kzaher/rxswiftcontent/master/GithubSearch.gif)
## Installation
Rx doesn't contain any external dependencies.
These are currently supported options:
### Manual
Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run sample app
### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html)
**:warning: IMPORTANT! For tvOS support CocoaPods `0.39` is required. :warning:**
```
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'RxSwift', '~> 2.0'
pod 'RxCocoa', '~> 2.0'
pod 'RxBlocking', '~> 2.0'
pod 'RxTests', '~> 2.0'
end
```
replace `YOUR_TARGET_NAME`, then type in the `Podfile` directory:
```
$ pod install
```
### [Carthage](https://github.com/Carthage/Carthage)
**Xcode 7.1 required**
Add this to `Cartfile`
```
github "ReactiveX/RxSwift" ~> 2.0
```
```
$ carthage update
```
### Manually using git submodules
* Add RxSwift as a submodule
```
$ git submodule add git@github.com:ReactiveX/RxSwift.git
```
* Drag `Rx.xcodeproj` into Project Navigator
* Go to `Project > Targets > Build Phases > Link Binary With Libraries`, click `+` and select `RxSwift-[Platform]` and `RxCocoa-[Platform]` targets
## References
* [http://reactivex.io/](http://reactivex.io/)
* [Reactive Extensions GitHub (GitHub)](https://github.com/Reactive-Extensions)