TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2016 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Mark Sands, James Rantanen.
Simple RxSwift extensions for interacting with Apple APIs.
<~
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
.
++
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
}
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:
object.rxs.disposeBag
- a collection of dispoasables that will be disposed on deinit
button.rxs.tap
- an Observable<Void>
that sends an event on every .TouchUpInside
control event.
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.
Same as UITextField, but using the UITextViewTextDidChangeNotification
to drive events
TargetActionObservable
and ValueBinding
provide the building blocks for creating your own interface “sugar” similar to the examples above.