Latest 0.1.1
Homepage https://github.com/RxSugar/RxSugar
License MIT
Platforms ios 8.0, tvos 9.0, requires ARC
Dependencies RxSwift
Authors , ,

RxSugar Logo RxSugar

Travis CI platforms Carthage compatible pod License

Simple RxSwift extensions for interacting with Apple APIs.

Operators that improve visualization of data flow

observer <~ observable

The <~ subscribes an observer to an observable.
Observer can be any ObserverType, Variable, or (value)->()closure.
Observable can be any ObservableType, Variable, or ObservableConvertibleType.
This operator returns a Disposable.

disposableCollection ++ disposable

The ++ appends a Disposable to a collection of disposables (DisposeBag or CompositeDisposable) and returns the collection.

These operators used in combination result in an easy to visualize data flow:

static func bindView(view: View, model: Model, selectionHandler:(SearchResult)->()) {
    view.rxs.disposeBag
        ++ view.searchResults <~ model.searchResults
        ++ model.searchTerm <~ view.searchTerm
        ++ selectionHandler <~ view.selectionEvents
}

Foundation / UIKit extensions

RxSugar adds Sugar to all NSObjects as a property called rxs. The rxs property contains RxSwift bindings for many common APIs. Here are a few examples:

NSObject

object.rxs.disposeBag – a collection of dispoasables that will be disposed on deinit

UIButton

button.rxs.tap – an Observable<Void> that sends an event on every .TouchUpInside control event.

UITextField

textField.rxs.text – a ValueBinding<String> that sends an event on every .EditingChanged control event and sets the control’s text for every event sent to it.

textField.rxs.attributedText – a ValueBinding<NSAttributedString> that sends an event on every .EditingChanged control event and sets the control’s attributedText for every event sent to it.

UITextView

Same as UITextField, but using the UITextViewTextDidChangeNotification to drive events

Adding your own Sugar

TargetActionObservable and ValueBinding provide the building blocks for creating your own interface "sugar" similar to the examples above.

Latest podspec

{
    "name": "RxSugar",
    "version": "0.1.1",
    "summary": "Simple RxSwift extensions for interacting with Apple APIs",
    "description": "RxSugar adds simple UI extensions for interacting with Apple APIs, and includes custom operators.nnFor more information, see [the README](https://github.com/RxSugar/RxSugar).",
    "homepage": "https://github.com/RxSugar/RxSugar",
    "license": "MIT",
    "authors": {
        "James Rantanen": "jarinteractive[email protected]",
        "Mark Sands": "[email protected]",
        "Asynchrony": null
    },
    "source": {
        "git": "https://github.com/RxSugar/RxSugar.git",
        "tag": "v0.1.1"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    },
    "source_files": [
        "RxSugar/RxSugar.h",
        "RxSugar/**/*.{swift}"
    ],
    "exclude_files": "RxSugarTests",
    "tvos": {
        "exclude_files": "RxSugar/UISwitch+Sugar.swift"
    },
    "dependencies": {
        "RxSwift": [
            "~> 3.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This