API

RxSwift supported operators

In some cases there are multiple aliases for the same operator, because on different platforms / implementations, the same operation is sometimes named differently. Sometimes this is because of historical reasons, while sometimes because of reserved language keywords.

When lacking a strong community consensus, RxSwift will usually include multiple aliases.

Operators are stateless by default.

Creating Observables

Transforming Observables

Filtering Observables

Combining Observables

Error Handling Operators

Observable Utility Operators

Conditional and Boolean Operators

Mathematical and Aggregate Operators

Connectable Observable Operators

Creating new operators is also pretty straightforward.

RxCocoa extensions

iOS / OSX

  1. extension NSObject {
  2. public var rx_deallocated: Observable<Void> {}
  3. #if !DISABLE_SWIZZLING
  4. public var rx_deallocating: Observable<Void> {}
  5. #endif
  6. }
  1. extension NSObject {
  2. public func rx_observe<Element>(
  3. type: E.Type,
  4. _ keyPath: String,
  5. options: NSKeyValueObservingOptions = .New | .Initial,
  6. retainSelf: Bool = true
  7. ) -> Observable<Element?> {}
  8. #if !DISABLE_SWIZZLING
  9. public func rx_observeWeakly<Element>(
  10. type: E.Type,
  11. _ keyPath: String,
  12. options: NSKeyValueObservingOptions = .New | .Initial
  13. ) -> Observable<Element?> {}
  14. #endif
  15. }
  1. extension NSURLSession {
  2. public func rx_response(request: NSURLRequest) -> Observable<(NSData, NSURLResponse)> {}
  3. public func rx_data(request: NSURLRequest) -> Observable<NSData> {}
  4. public func rx_JSON(request: NSURLRequest) -> Observable<AnyObject> {}
  5. public func rx_JSON(URL: NSURL) -> Observable<AnyObject> {}
  6. }
  1. extension NSNotificationCenter {
  2. public func rx_notification(name: String, object: AnyObject?) -> Observable<NSNotification> {}
  3. }
  1. class DelegateProxy {
  2. public func observe(selector: Selector) -> Observable<[AnyObject]> {}
  3. }
  1. extension CLLocationManager {
  2. public var rx_delegate: DelegateProxy {}
  3. public var rx_didUpdateLocations: Observable<[CLLocation]> {}
  4. public var rx_didFailWithError: Observable<NSError> {}
  5. public var rx_didFinishDeferredUpdatesWithError: Observable<NSError> {}
  6. public var rx_didPauseLocationUpdates: Observable<Void> {}
  7. public var rx_didResumeLocationUpdates: Observable<Void> {}
  8. public var rx_didUpdateHeading: Observable<CLHeading> {}
  9. public var rx_didEnterRegion: Observable<CLRegion> {}
  10. public var rx_didExitRegion: Observable<CLRegion> {}
  11. public var rx_didDetermineStateForRegion: Observable<(state: CLRegionState, region: CLRegion)> {}
  12. public var rx_monitoringDidFailForRegionWithError: Observable<(region: CLRegion?, error: NSError)> {}
  13. public var rx_didStartMonitoringForRegion: Observable<CLRegion> {}
  14. public var rx_didRangeBeaconsInRegion: Observable<(beacons: [CLBeacon], region: CLBeaconRegion)> {}
  15. public var rx_rangingBeaconsDidFailForRegionWithError: Observable<(region: CLBeaconRegion, error: NSError)> {}
  16. public var rx_didVisit: Observable<CLVisit> {}
  17. public var rx_didChangeAuthorizationStatus: Observable<CLAuthorizationStatus> {}
  18. }

iOS

  1. extension UIControl {
  2. public func rx_controlEvent(controlEvents: UIControlEvents) -> ControlEvent<Void> {}
  3. public var rx_enabled: ObserverOf<Bool> {}
  4. }
  1. extension UIButton {
  2. public var rx_tap: ControlEvent<Void> {}
  3. }
  1. extension UITextField {
  2. public var rx_text: ControlProperty<String> {}
  3. }
  1. extension UITextView {
  2. override func rx_createDelegateProxy() -> RxScrollViewDelegateProxy {}
  3. public var rx_text: ControlProperty<String> {}
  4. }
  1. extension UISearchBar {
  2. public var rx_delegate: DelegateProxy {}
  3. public var rx_searchText: ControlProperty<String> {}
  4. }
  1. extension UILabel {
  2. public var rx_text: ObserverOf<String> {}
  3. }
  1. extension UIDatePicker {
  2. public var rx_date: ControlProperty<NSDate> {}
  3. }
  1. extension UIImageView {
  2. public var rx_image: ObserverOf<UIImage!> {}
  3. public func rx_imageAnimated(transitionType: String?) -> AnyObserver<UIImage?>
  4. }
  1. extension UIScrollView {
  2. public var rx_delegate: DelegateProxy {}
  3. public func rx_setDelegate(delegate: UIScrollViewDelegate) {}
  4. public var rx_contentOffset: ControlProperty<CGPoint> {}
  5. }
  1. extension UIBarButtonItem {
  2. public var rx_tap: ControlEvent<Void> {}
  3. }
  1. extension UISlider {
  2. public var rx_value: ControlProperty<Float> {}
  3. }
  1. extension UITableView {
  2. public var rx_dataSource: DelegateProxy {}
  3. public func rx_setDataSource(dataSource: UITableViewDataSource) -> Disposable {}
  4. public func rx_itemsWithCellFactory(source: O)(cellFactory: (UITableView, Int, S.Generator.Element) -> UITableViewCell) -> Disposable {}
  5. public func rx_itemsWithCellIdentifier(cellIdentifier: String, cellType: Cell.Type = Cell.self)(source: O)(configureCell: (Int, S.Generator.Element, Cell) -> Void) -> Disposable {}
  6. public func rx_itemsWithDataSource(dataSource: DataSource)(source: O) -> Disposable {}
  7. public var rx_itemSelected: ControlEvent<NSIndexPath> {}
  8. public var rx_itemDeselected: ControlEvent<NSIndexPath> {}
  9. public var rx_itemInserted: ControlEvent<NSIndexPath> {}
  10. public var rx_itemDeleted: ControlEvent<NSIndexPath> {}
  11. public var rx_itemMoved: ControlEvent<ItemMovedEvent> {}
  12. // This method only works in case one of the `rx_itemsWith*` methods was used, or data source implements `SectionedViewDataSourceType`
  13. public func rx_modelSelected<T>(modelType: T.Type) -> ControlEvent<T> {}
  14. // This method only works in case one of the `rx_itemsWith*` methods was used, or data source implements `SectionedViewDataSourceType`
  15. public func rx_modelDeselected<T>(modelType: T.Type) -> ControlEvent<T> {}
  16. }
  1. extension UICollectionView {
  2. public var rx_dataSource: DelegateProxy {}
  3. public func rx_setDataSource(dataSource: UICollectionViewDataSource) -> Disposable {}
  4. public func rx_itemsWithCellFactory(source: O)(cellFactory: (UICollectionView, Int, S.Generator.Element) -> UICollectionViewCell) -> Disposable {}
  5. public func rx_itemsWithCellIdentifier(cellIdentifier: String, cellType: Cell.Type = Cell.self)(source: O)(configureCell: (Int, S.Generator.Element, Cell) -> Void) -> Disposable {}
  6. public func rx_itemsWithDataSource(dataSource: DataSource)(source: O) -> Disposable {}
  7. public var rx_itemSelected: ControlEvent<NSIndexPath> {}
  8. public var rx_itemDeselected: ControlEvent<NSIndexPath> {}
  9. // This method only works in case one of the `rx_itemsWith*` methods was used, or data source implements `SectionedViewDataSourceType`
  10. public func rx_modelSelected<T>(modelType: T.Type) -> ControlEvent<T> {}
  11. // This method only works in case one of the `rx_itemsWith*` methods was used, or data source implements `SectionedViewDataSourceType`
  12. public func rx_modelSelected<T>(modelType: T.Type) -> ControlEvent<T> {}
  13. }
  1. extension UIGestureRecognizer {
  2. public var rx_event: ControlEvent<UIGestureRecognizer> {}
  3. }
  1. extension UIImagePickerController {
  2. public var rx_didFinishPickingMediaWithInfo: Observable<[String : AnyObject]> {}
  3. public var rx_didCancel: Observable<()> {}
  4. }
  1. extension UISegmentedControl {
  2. public var rx_value: ControlProperty<Int> {}
  3. }
  1. extension UISwitch {
  2. public var rx_value: ControlProperty<Bool> {}
  3. }
  1. extension UIActivityIndicatorView {
  2. public var rx_animating: AnyObserver<Bool> {}
  3. }
  1. extension UINavigationItem {
  2. public var rx_title: AnyObserver<String?> {}
  3. }

OSX

  1. extension NSControl {
  2. public var rx_controlEvent: ControlEvent<()> {}
  3. public var rx_enabled: AnyObserver<Bool> {}
  4. }
  1. extension NSSlider {
  2. public var rx_value: ControlProperty<Double> {}
  3. }
  1. extension NSButton {
  2. public var rx_tap: ControlEvent<Void> {}
  3. public var rx_state: ControlProperty<Int> {}
  4. }
  1. extension NSImageView {
  2. public var rx_image: ObserverOf<NSImage?> {}
  3. public func rx_imageAnimated(transitionType: String?) -> AnyObserver<NSImage?>
  4. }
  1. extension NSTextField {
  2. public var rx_delegate: DelegateProxy {}
  3. public var rx_text: ControlProperty<String> {}
  4. }
  1. extension UITabBarItem {
  2. public var rx_badgeValue: AnyObserver<String?> {}
  3. }