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

migrating-from-promise-to-reactive

 migrating-from-promise-to-reactive

Gotanda.mobile #2 in VASILY (https://gotandamb.connpass.com/event/50876/)

horimislime

March 23, 2017
Tweet

More Decks by horimislime

Other Decks in Technology

Transcript

  1. enum AppError: Error { case offline case network } get(userId:

    1234).then { user in ... }.catch { error in // ! switch error as! AppError { ... } } 7
  2. Promise෩ຯͳReactiveKit findPrinter() .flatMapLatesst { printer in return send(document, to: printer)

    }.flatMapLatest { result in return process(result) }.observe { event in switch event { case .completed: Progress.dismiss() case .failed(let error): switch error { case .network: Progress.showError("Network error!") ... } } } 10