Giter Club home page Giter Club logo

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.

rxsugar's Projects

rxsugar icon rxsugar

Simple RxSwift extensions for interacting with Apple APIs

searchy icon searchy

Searchy is a small app that uses the MVB pattern with RxSwift to search the iTunes API and display songs and cover art.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.