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

Reactive Thinking in iOS Development - Reactive...

Reactive Thinking in iOS Development - Reactive Amsterdam Meetup

In a world where Imperative Programming is the most used paradigm, Reactive comes up to make our code more reusable, robust, and stateless. Learn what Functional Reactive Programming means and how it could help you with problems you have to face daily in your projects. We’ll present basic concepts and practical examples for iOS developers that will help you to start thinking in streams, observers, .. and mix them with cool Swift functional concepts.

Pedro Piñera Buendía

May 12, 2016
Tweet

More Decks by Pedro Piñera Buendía

Other Decks in Technology

Transcript

  1. WHO? @pepibumur iOS Developer at SoundCloud GitHub: pepibumur Twitter: pepibumur

    @saky iOS Developer at Letgo GitHub: isaacroldan Twitter: saky GitDo.io our spare time project
  2. INDEX 1. Why Reactive? I'm happy being imperative 2. What

    do we need? 3. How can I be Reactive? 4. It looks magic. Any Downside?
  3. REACTIVECOCOA Version 1.0 (Objective-C) - February 2014 Version 2.0 (Objective-C)

    - September 2014 Version 3.0 (Objective-C) - September 2015 Swift launch - June 2014 Version 4.0 (Swift) - January 2015
  4. RXSWIFT > More aligned to Rx > Not external dependencies.

    > More aligned with Swift error handling. > It provides extensions for Cocoa/UIKit, RxCocoa
  5. THERE ARE SOME OTHERS > BrightFutures > ReactKit > Bond

    > More and more... PromiseKit, Bolts...
  6. let tracksFetcher = api.fetchTracks // Background .asObservable() .retry(3) .catchErrorJustReturn([]) .map(TrackEntity.mapper().map)

    .filter { $0.name.contains(query) } .flatMap { self.rx_trackImage(track: $0) } .observeOn(MainScheduler.instance) // Main thread
  7. let tracksFetcher = api.fetchTracks // Background .asObservable .debug("after_fetch") // <--

    Debugging probes .retry(3) .catchErrorJustReturn([]) .map(TrackEntity.mapper().map) .debug("mapped_results") // <-- Debugging probes .filter { $0.name.contains(query) } .flatMap { self.rx_trackImage(track: $0) } .observeOn(MainScheduler.instance) // Main thread
  8. //let tracksFetcher = api.fetchTracks // Background // .asObservable .debug("after_fetch") //

    <-- Debugging probes // .retry(3) // .catchErrorJustReturn([]) // .map(TrackEntity.mapper().map) .debug("mapped_results") // <-- Debugging probes // .filter { $0.name.contains(query) } // .flatMap { self.rx_trackImage(track: $0) } // .observeOn(MainScheduler.instance) // Main thread