Skip to content
RxSwift Extension for easier use of observe
Swift Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
Sources/RxObserve
.gitignore
.travis.yml
LICENSE
README.md
RxObserve.podspec
_Pods.xcodeproj

README.md

RxObserve

CI Status Version License Platform

RxObserve is an extension that allows you to use observe with keypath.

Getting Started

class SomeObject: NSObject {
  @objc dynamic var text: String = ""
}

let object = SomeObject()
// in RxCocoa observe, Optional type and must be typed and is a string keypath.
let textObservable = object.rx.observe(String.self, "text") // observe in RxCocoa, It's type is Observable<String?>

// RxObserve
let textObservable = object.rx.asObservable(keyPath: \.text) // It's type is Observable<String>
let textObservable = object.rx.asObservable(keyPath: \.text, options: [.new]) // default value for options is [.initial, .new]

let textObserver = object.rx.asObserver(keyPath: \.text) // It's type is AnyObserver<String>

let view = UIView()
let backgroundColorObservable = view.rx.asObservable(keyPath: \.backgroundColor) // It's type is Observable<UIColor?>

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

RxObserve is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RxObserve'

Author

kjisoo, kim@jisoo.net

License

RxObserve is available under the MIT license. See the LICENSE file for more info.

You can’t perform that action at this time.