<p align="center">
<img src="assets/RxSwift_Logo.png" width="35%" alt="RxSwift Logo" />
<br />
<a href="https://actions-badge.atrox.dev/ReactiveX/RxSwift/goto" target="_blank"><img src="https://github.com/ReactiveX/RxSwift/workflows/RxSwift/badge.svg?branch=main" alt="Build Status" /></a>
<img src="https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg" alt="Supported Platforms: iOS, macOS, tvOS, watchOS & Linux" />
<br />
<a href="https://cocoapods.org/pods/RxSwift" alt="RxSwift on CocoaPods" title="RxSwift on CocoaPods"><img src="https://img.shields.io/cocoapods/v/RxSwift.svg" /></a>
<a href="https://github.com/Carthage/Carthage" alt="RxSwift on Carthage" title="RxSwift on Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" /></a>
<a href="https://github.com/apple/swift-package-manager" alt="RxSwift on Swift Package Manager" title="RxSwift on Swift Package Manager"><img src="https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg" /></a>
</p>
Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable<Element>` interface, which lets you broadcast and subscribe to values and other events from an `Observable` stream.
RxSwift is the Swift-specific implementation of the [Reactive Extensions](http://reactivex.io) standard.
<p align="center"><img src="assets/example.png" width="55%" alt="RxSwift Observable Example of a price constantly changing and updating the app's UI" /></p>
While this version aims to stay true to the original spirit and naming conventions of Rx, this projects also aims to provide a true Swift-first API for Rx APIs.
Cross platform documentation can be found on [ReactiveX.io](http://reactivex.io/).
Like other Rx implementation, RxSwift's intention is to enable easy composition of asynchronous operations and streams of data in the form of `Observable` objects and a suite of methods to transform and compose these pieces of asynchronous work.
KVO observation, async operations, UI Events and other streams of data are all unified under [abstraction of sequence](Documentation/GettingStarted.md#observables-aka-sequences). This is the reason why Rx is so simple, elegant and powerful.
## I came here because I want to ...
###### ... understand
* [why use rx?](Documentation/Why.md)
* [the basics, getting started with RxSwift](Documentation/GettingStarted.md)
* [traits](Documentation/Traits.md) - what are `Single`, `Completable`, `Maybe`, `Driver`, and `ControlProperty` ... and why do they exist?
* [testing](Documentation/UnitTests.md)
* [tips and common errors](Documentation/Tips.md)
* [debugging](Documentation/GettingStarted.md#debugging)
* [the math behind Rx](Documentation/MathBehindRx.md)
* [what are hot and cold observable sequences?](Documentation/HotAndColdObservables.md)
###### ... install
* Integrate RxSwift/RxCocoa with my app. [Installation Guide](#installation)
###### ... hack around
* with the example app. [Running Example App](Documentation/ExampleApp.md)
* with operators in playgrounds. [Playgrounds](Documentation/Playgrounds.md)
###### ... interact
* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences. <br />[Join Slack Channel](http://slack.rxswift.org)
* Report a problem using the library. [Open an Issue With Bug Template](.github/ISSUE_TEMPLATE.md)
* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md)
* Help out [Check out contribution guide](CONTRIBUTING.md)
###### ... compare
* [with Combine and ReactiveSwift](Documentation/ComparisonWithOtherLibraries.md).
###### ... understand the structure
RxSwift is as compositional as the asynchronous work it drives. The core unit is RxSwift itself, while other dependencies can be added for UI Work, testing, and more.
It comprises five separate components depending on each other in the following way:
```none
┌──────────────┐ ┌──────────────┐
│ RxCocoa ├────▶ RxRelay │
└───────┬──────┘ └──────┬───────┘
│ │
┌───────▼──────────────────▼───────┐
│ RxSwift │
└───────▲──────────────────▲───────┘
│ │
┌───────┴──────┐ ┌──────┴───────┐
│ RxTest │ │ RxBlocking │
└──────────────┘ └──────────────┘
```
* **RxSwift**: The core of RxSwift, providing the Rx standard as (mostly) defined by [ReactiveX](https://reactivex.io). It has no other dependencies.
* **RxCocoa**: Provides Cocoa-specific capabilities for general iOS/macOS/watchOS & tvOS app development, such as Shared Sequences, Traits, and much more. It depends on both `RxSwift` and `RxRelay`.
* **RxRelay**: Provides `PublishRelay`, `BehaviorRelay` and `ReplayRelay`, three [simple wrappers around Subjects](https://github.com/ReactiveX/RxSwift/blob/main/Documentation/Subjects.md#relays). It depends on `RxSwift`.
* **RxTest** and **RxBlocking**: Provides testing capabilities for Rx-based systems. It depends on `RxSwift`.
## Usage
<table>
<tr>
<th width="30%">Here's an example</th>
<th width="30%">In Action</th>
</tr>
<tr>
<td>Define search for GitHub repositories ...</td>
<th rowspan="9"><img src="https://raw.githubusercontent.com/kzaher/rxswiftcontent/master/GithubSearch.gif"></th>
</tr>
<tr>
<td><div class="highlight highlight-source-swift"><pre>
let searchResults = searchBar.rx.text.orEmpty
.throttle(.milliseconds(300), scheduler: MainScheduler.instance)
.distinctUntilChanged()
.flatMapLatest { query -> Observable<[Repository]> in
if query.isEmpty {
return .just([])
}
return searchGitHub(query)
.catchAndReturn([])
}
.observe(on: MainScheduler.instance)</pre></div></td>
</tr>
<tr>
<td>... then bind the results to your tableview</td>
</tr>
<tr>
<td width="30%"><div class="highlight highlight-source-swift"><pre>
searchResults
.bind(to: tableView.rx.items(cellIdentifier: "Cell")) {
(index, repository: Repository, cell) in
cell.textLabel?.text = repository.name
cell.detailTextLabel?.text = repository.url
}
.disposed(by: disposeBag)</pre></div></td>
</tr>
</table>
## Requirements
* Xcode 12.x
* Swift 5.x
For Xcode 11 and below, [use RxSwift 5.x](https://github.com/ReactiveX/RxSwift/releases/tag/5.1.1).
## Installation
RxSwift doesn't contain any external dependencies.
These are currently the supported installation options:
### Manual
Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run the sample app
### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html)
```ruby
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'RxSwift', '6.5.0'
pod 'RxCocoa', '6.5.0'
end
# RxTest and RxBlocking make the most sense in the context of unit/integration tests
target 'YOUR_TESTING_TARGET' do
pod 'RxBlocking', '6.5.0'
pod 'RxTest', '6.5.0'
end
```
Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type:
```bash
$ pod install
```
### XCFrameworks
Each release starting with RxSwift 6 includes `*.xcframework` framework binaries.
Simply drag the needed framework binaries to your **Frameworks, Libraries, and Embedded Content** section under your target's **General** tab.
> **Note**: If you're using `RxCocoa`, be sure to also drag **RxCocoaRuntime.xcframe
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
iOS-RxSwift基础控件的使用、RxSwif-Tableview的使用-Demo (398个子文件)
.DS_Store 6KB
_RXObjCRuntime.h 4KB
_RX.h 4KB
_RXKVOObserver.h 801B
_RXDelegateProxy.h 741B
RxCocoa.h 495B
RxCocoaRuntime.h 470B
RxCocoa-umbrella.h 452B
Pods-CSDN-RxSwift-umbrella.h 326B
Differentiator-umbrella.h 320B
RxDataSources-umbrella.h 318B
RxRelay-umbrella.h 306B
RxSwift-umbrella.h 306B
Contents.json 2KB
Contents.json 123B
Contents.json 63B
Podfile.lock 821B
Manifest.lock 821B
_RXObjCRuntime.m 48KB
_RXDelegateProxy.m 4KB
_RXKVOObserver.m 1KB
_RX.m 160B
Pods-CSDN-RxSwift-dummy.m 138B
Differentiator-dummy.m 132B
RxDataSources-dummy.m 130B
RxCocoa-dummy.m 118B
RxRelay-dummy.m 118B
RxSwift-dummy.m 118B
Pods-CSDN-RxSwift-acknowledgements.markdown 6KB
README.md 11KB
README.md 11KB
README.md 11KB
README.md 7KB
README.md 7KB
LICENSE.md 1KB
LICENSE.md 1KB
LICENSE.md 1KB
LICENSE.md 1KB
LICENSE.md 1KB
Pods-CSDN-RxSwift.modulemap 124B
Differentiator.modulemap 118B
RxDataSources.modulemap 116B
RxCocoa.modulemap 104B
RxSwift.modulemap 104B
RxRelay.modulemap 104B
project.pbxproj 233KB
project.pbxproj 21KB
RxRelay-prefix.pch 195B
RxDataSources-prefix.pch 195B
RxCocoa-prefix.pch 195B
Differentiator-prefix.pch 195B
RxSwift-prefix.pch 195B
Pods-CSDN-RxSwift-acknowledgements.plist 7KB
xcschememanagement.plist 1KB
Differentiator-Info.plist 828B
RxRelay-Info.plist 828B
RxSwift-Info.plist 828B
RxCocoa-Info.plist 828B
Pods-CSDN-RxSwift-Info.plist 828B
RxDataSources-Info.plist 828B
Info.plist 704B
xcschememanagement.plist 347B
IDEWorkspaceChecks.plist 238B
IDEWorkspaceChecks.plist 238B
Podfile 322B
Pods-CSDN-RxSwift-frameworks.sh 9KB
Main.storyboard 10KB
LaunchScreen.storyboard 2KB
Zip+arity.swift 42KB
SharedSequence+Operators+arity.swift 41KB
CombineLatest+arity.swift 41KB
Infallible+Operators.swift 34KB
Diff.swift 32KB
PrimitiveSequence+Zip+arity.swift 32KB
SharedSequence+Operators.swift 28KB
Merge.swift 22KB
NSObject+Rx.swift 19KB
DelegateProxyType.swift 18KB
Single.swift 18KB
PrimitiveSequence.swift 18KB
Maybe.swift 17KB
UITableView+Rx.swift 16KB
UICollectionView+Rx.swift 16KB
Multicast.swift 15KB
ShareReplayScope.swift 14KB
Completable.swift 13KB
DelegateProxy.swift 12KB
RetryWhen.swift 10KB
Catch.swift 10KB
TakeWithPredicate.swift 10KB
UIPickerView+Rx.swift 9KB
Switch.swift 9KB
Driver+Subscription.swift 9KB
Infallible+CombineLatest+arity.swift 9KB
RxCocoaObjCRuntimeError+Extensions.swift 9KB
SharedSequence.swift 8KB
TableViewSectionedDataSource.swift 8KB
URLSession+Rx.swift 8KB
VirtualTimeScheduler.swift 8KB
RxPickerViewAdapter.swift 8KB
共 398 条
- 1
- 2
- 3
- 4
宇夜iOS
- 粉丝: 4153
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0