Upgrade to Pro — share decks privately, control downloads, hide ads and more …

So You Want To Be A Reactive Programming Beginner?

Greg Heo
February 01, 2017

So You Want To Be A Reactive Programming Beginner?

RxSwift basics @ NSMeetup, February 1, 2017.

Blog post and some notes here: https://gregheo.com/blog/nsmeetup-rx/

Greg Heo

February 01, 2017
Tweet

More Decks by Greg Heo

Other Decks in Technology

Transcript

  1. @gregheo let angleSliderObservable = angleSlider.rx.value .map({ (angle: Float) in return

    RightTriangle(angle: Int(angle)) }) let oppositeAngleSliderObservable = oppositeAngleSlider.rx.value .map({ (angle: Float) in return RightTriangle(oppositeAngle: Int(angle)) }) let combinedObservable = Observable.of(angleSliderObservable, oppositeAngleSliderObservable).merge()
  2. @gregheo let angleSliderObservable = angleSlider.rx.value .map({ (angle: Float) in return

    RightTriangle(angle: Int(angle)) }) let oppositeAngleSliderObservable = oppositeAngleSlider.rx.value .map({ (angle: Float) in return RightTriangle(oppositeAngle: Int(angle)) }) let combinedObservable = Observable.of(angleSliderObservable, oppositeAngleSliderObservable).merge() combinedObservable .subscribe(onNext: { (triangle: RightTriangle) in self.angleSlider.value = Float(triangle.angle) self.triangleView.triangle = triangle }) .addDisposableTo(disposeBag) combinedObservable .map({ "Angle: \($0.angle)°\nOpposite angle: \($0.oppositeAngle)°" }) .bindTo(label.rx.text) .addDisposableTo(disposeBag)
  3. @gregheo let angleSliderObservable = angleSlider.rx.value .map({ (angle: Float) in return

    RightTriangle(angle: Int(angle)) }) let oppositeAngleSliderObservable = oppositeAngleSlider.rx.value .map({ (angle: Float) in return RightTriangle(oppositeAngle: Int(angle)) }) let combinedObservable = Observable.of(angleSliderObservable, oppositeAngleSliderObservable).merge() combinedObservable .subscribe(onNext: { (triangle: RightTriangle) in self.angleSlider.value = Float(triangle.angle) self.triangleView.triangle = triangle }) .addDisposableTo(disposeBag) combinedObservable .map({ "Angle: \($0.angle)°\nOpposite angle: \($0.oppositeAngle)°" }) .bindTo(label.rx.text) .addDisposableTo(disposeBag) Reactive Extensions input output