Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MCE^3 - Ágnes Vásárhelyi - ReactiveCocoa Reloaded

80 views

Published on

ReactiveCocoa is the first and most commonly used implementation of the reactive paradigms in Cocoa, with a lot of bindings to UIKit/AppKit frameworks to help connecting reactive signals to UI elements. I was lucky to work on a huge Objective-C codebase with heavy use of ReactiveCocoa prepared to be released for millions of users, so I have some pros and cons in my pocket even for that scale. I'd like to discuss the state of ReactiveCocoa in 2016, to help people to understand their possibilities especially if they are in the phase of moving to Swift. I'd like to share the main differences of the new ReactiveCocoa Swift API with code snippets. What are the conceptual changes, in comparison to the v2 Objective-C API. Some examples of other libs, like RxSwift and what are the main differences in usage.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

MCE^3 - Ágnes Vásárhelyi - ReactiveCocoa Reloaded

  1. 1. Reactivecocoa reloaded or how to RAC in 2016? Agnes Vasarhelyi @vasarhelyia
  2. 2. “Capturing and responding to changes has a long tradition in Cocoa, and ReactiveCocoa is a conceptual and functional extension of that.” — @mattt
  3. 3. Reactive
  4. 4. T Async data stream
  5. 5. T T T ⨁ Operators
  6. 6. objective-c
  7. 7. RACSignal 🔥❄
  8. 8. Signal 🔥 T Observer 1 Observer 2
  9. 9. T Observer 1 Signal ❄ Observer 2
  10. 10. Next Error Completed
  11. 11. Next new value
  12. 12. Completed there are no more values
  13. 13. ERROR signal couldn’t finish
  14. 14. Subscribe listen to signal changes Next/Error/Completed
  15. 15. Side effects doNext..
  16. 16. RACObserve [[RACObserve(self, username) filter:^(NSString *name) { return [name hasPrefix:@"a"]; }] subscribeNext:^(NSString *name) { NSLog(@"%@", name); }];
  17. 17. RAC( ) RAC(self, enabled) = [RACSignal ...];
  18. 18. RACSequence transforming collections
  19. 19. UI RACCommand bindings
  20. 20. Swift
  21. 21. Event Signal SignalProducer
  22. 22. Event “something has happened”
  23. 23. Event T Signal
  24. 24. .Next .Completed .Failed .Interrupted
  25. 25. Next new value value as payload
  26. 26. Completed there is no more of it
  27. 27. Failed signal couldn’t finish <ErrorType> .NoError
  28. 28. Interrupted signal has been cancelled
  29. 29. Signal 🔥 synchronous event stream
 observe to access events
  30. 30. SignalProducer ❄ start() startWithSignal()
  31. 31. Observation signal.observe( Signal.Observer { switch event { case let .Next(next): print("(next)")
 ... }
 })
  32. 32. Side effects signalProducer .on(failed: { error in print(“Error 😱: (error)”) }, completed: { print(“done!") })
  33. 33. PRoperty observable value
  34. 34. UI Action/CocoaAction
  35. 35. REACTIVE EVERYWherE 🙃
  36. 36. async ops ✅ UI bindings ✅ business logic 🚫
  37. 37. RxSwift ReactiveX cross-platform lot of docs, big community Swift Observable
  38. 38. ReactiveKit Interstellar PromiseKit Bolts VinceRP …
  39. 39. in PRoduction Prezi, SoundCloud: RAC & Objective-C Fabric: RAC & Swift Artsy: RxSwift (OSS) …
  40. 40. 🤗 @bvic23 @cocagrinder @Javi @kastiglione @itchingpixels @ashfurrow @icanzilb
  41. 41. Questions? Thank you! @vasarhelyia
 alltheflow.com

×