Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
migrating-from-promise-to-reactive
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
horimislime
March 23, 2017
Technology
410
0
Share
migrating-from-promise-to-reactive
Gotanda.mobile #2 in VASILY (
https://gotandamb.connpass.com/event/50876/
)
horimislime
March 23, 2017
More Decks by horimislime
See All by horimislime
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
380
スタートアップの急成長に寄り添うOn-Call体制構築とその変遷
horimislime
3
2.1k
How we build our app with minimum 3rd party dependencies
horimislime
0
110
サポート効率を上げるためのロギング環境構築
horimislime
7
3.9k
社内Swiftもくもく会成果発表
horimislime
0
150
Swift Optional Extension Tips
horimislime
1
1.7k
ios-internationalization
horimislime
2
9k
UI testing in XCode7
horimislime
3
860
UIテストをカジュアルに自動化 / UI Automation using Remote
horimislime
2
2.5k
Other Decks in Technology
See All in Technology
あるアーキテクチャ決定と その結果/architecture-decision-and-its-result
hanhan1978
2
590
DevOpsDays Tokyo 2026 見えない開発現場を、見える投資に変える
rojoudotcom
2
170
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
5
13k
Code Interpreter で、AIに安全に コードを書かせる。
yokomachi
0
790
"SQLは書けません"から始まる データドリブン
kubell_hr
1
320
プロンプトエンジニアリングを超えて:自由と統制のあいだでつくる Platform × Context Engineering
yuriemori
0
180
名刺メーカーDevグループ 紹介資料
sansan33
PRO
0
1.1k
ADOTで始めるサーバレスアーキテクチャのオブザーバビリティ
alchemy1115
2
280
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
180
DevOpsDays2026 Tokyo Cross-border practices to connect "safety" and "DX" in healthcare
hokkai7go
0
130
ログ基盤・プラグイン・ダッシュボード、全部整えた。でも最後は人だった。
makikub
5
1.7k
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
380
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
680
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
Paper Plane
katiecoart
PRO
1
49k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.4k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
330
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
490
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Evolving SEO for Evolving Search Engines
ryanjones
0
180
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
Transcript
Promise͔ΒReactiveͷҠߦΛࡧ͢Δ Gotanda.mobile #2 @horimislime 1
self • @horimislime • גࣜձࣾτϨλ @ޒాTOC • ҿ৯ళ͚iPadாΞϓϦΛ։ൃͯ͠·͢ 2
͓ • PromiseͰඇಉظϓϩάϥϛϯά͍ͯ͠Δ/͠Α͏ͱ͍ͯ͠Δਓ ʹReactiveΛΦεεϝ͢Δ • ࣾͷΞϓϦͰͷࣄྫΛఴ͑ͯ 3
Objective-Cࢿ࢈ͷ͋ΔΞϓϦ • BoltsFrameworkʹΑΔPromise • APIClient͕BoltsͷTaskΛฦ͢ • ্ҐͰൣғʹBoltsʹґଘ 4
ͦͯ͠SwiftҠߦظ • BoltsAnyObject͕ฦ͖ͬͯͯπϥ͍ • SwiftyͳPromiseͷඞཁੑ • ͦͷޙ৭ʑ͋ͬͯҎԼʹґଘ͍ͯ͠Δ • Bolts-Objc •
SwiftTask • Bolts-Swift 5
PromiseͰͷ՝ײ • ଟ͘ͷͷͰErrorͷܕࢦఆ͕Ͱ͖ͳ͍ࣄͷෆຬ • ϝϯςφϯε͕׆ൃͰͳ͍ͷ͕ग़͖ͯͭͭ͋Δ 6
enum AppError: Error { case offline case network } get(userId:
1234).then { user in ... }.catch { error in // ! switch error as! AppError { ... } } 7
ɹɹɹ ݁Ռͷܕࢦఆ Errorͷܕࢦఆ Swift3 Bolts-Swift ✅ ❌ ✅ PromiseKit ✅
❌ ✅ SwiftTask ✅ ✅ ❌(branch༗) 8
Reactiveͷػӡ • SwiftҠߦͱڞʹSwiftBondΛ͍࢝Ίͯͨ • ReactiveKitͱ͍͏ମʹґଘ • PromiseͰΓ͍ͨࣄେମͰ͖Δ 9
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
ϝϦοτ • ͦΜͳʹҧײͳ͍͠ɺbinding͚ͩͰͳ͘ඇಉظॲཧָ͕ • طʹView bindingΛ͍ͬͯΕੑ˕ • ظతͳϝϯςφϯεͷظ 11
ಋೖͷোน • Reactiveͷֶशίετͷݒ೦ • ͜ͷ1͘Β͍ͰσϑΝΫτԽͨ͠ײ͕͋Δ • View Bindingʹ͏ͳΒશମతʹReactiveԽͨ͠ํ͕߹ ͕ྑ͍͜ͱଟ͍ 12
ߟ͓͖͑ͯ͘ࣄ • Promise / Rxؔ࿈ෳϨΠϠͰ༻͕ͪ͠ • Լखʹબ͢ΔͱେͳҠߦίετͰࢮ͵ • ࠷কདྷੑΛߟྀ͢Δ͖ॴ 13
·ͱΊ • SwiftΛऔΓר͘Promiseࣄ • ReactiveͷোนݮͬͯΔ͠ಋೖͷνϟϯε ! • ٕͨͩ͠ज़બఆ৻ॏʹ 14