Five Unbelievable Secrets of Reactive Programming the Experts Don't Want You to Know!

06609d73ad2165c4aafcf65a1ddb9563?s=47 Greg Heo
February 24, 2017

Five Unbelievable Secrets of Reactive Programming the Experts Don't Want You to Know!

Totally non-clickbaity article about lessons learned from reactive programming. Presented at Playgrounds, Melbourne, February 24, 2917.

06609d73ad2165c4aafcf65a1ddb9563?s=128

Greg Heo

February 24, 2017
Tweet

Transcript

  1. 3.
  2. 11.
  3. 16.

    .map({ (point: NSPoint) -> Int in for (i, squareView) in

    squareViews.enumerated() { if squareView.frame.contains(point) { return i } } }) vc.rx_mouseClicks an observable (aka a sequence) 0 1 2 3 4 5 6 7 8
  4. 19.
  5. 22.

    gameController.resultObservable .subscribe(onNext: { moveResult in switch moveResult { case .win(let

    winner): let alert = NSAlert()
 // Show alert for winner case .draw: let alert = NSAlert()
 // Show alert for draw case .success(nextPlayer: player):
 // ... case .invalid(nextPlayer: player): // ... } })
  6. 26.
  7. 28.

    Game
 controller let moves: [Int] = [1, 3, 52, 4]

    [.success(nextPlayer: .nought), .success(nextPlayer: .cross), .success(nextPlayer: .nought)] .invalid(nextPlayer: .cross),
  8. 30.
  9. 32.

    1. You already know it 2. Sequences everywhere 3. Small

    pieces of logic 4. Declarative style 5. Testable code
  10. 33.