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
horimislime
March 23, 2017
Technology
0
400
migrating-from-promise-to-reactive
Gotanda.mobile #2 in VASILY (
https://gotandamb.connpass.com/event/50876/
)
horimislime
March 23, 2017
Tweet
Share
More Decks by horimislime
See All by horimislime
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
280
スタートアップの急成長に寄り添うOn-Call体制構築とその変遷
horimislime
3
1.8k
How we build our app with minimum 3rd party dependencies
horimislime
0
96
サポート効率を上げるためのロギング環境構築
horimislime
7
3.9k
社内Swiftもくもく会成果発表
horimislime
0
130
Swift Optional Extension Tips
horimislime
1
1.6k
ios-internationalization
horimislime
2
8.9k
UI testing in XCode7
horimislime
3
800
UIテストをカジュアルに自動化 / UI Automation using Remote
horimislime
2
2.4k
Other Decks in Technology
See All in Technology
Model Mondays S2E02: Model Context Protocol
nitya
0
150
Perk アプリの技術選定とリリースから1年弱経ってのふりかえり
stomk
0
120
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
11
3.4k
ObsidianをMCP連携させてみる
ttnyt8701
2
140
Azure AI Foundryでマルチエージェントワークフロー
seosoft
0
130
AIのAIによるAIのための出力評価と改善
chocoyama
0
360
キャディでのApache Iceberg, Trino採用事例 -Apache Iceberg and Trino Usecase in CADDi--
caddi_eng
0
170
Workflows から Agents へ ~ 生成 AI アプリの成長過程とアプローチ~
belongadmin
3
170
新卒3年目の後悔〜機械学習モデルジョブの運用を頑張った話〜
kameitomohiro
0
350
AIエージェント最前線! Amazon Bedrock、Amazon Q、そしてMCPを使いこなそう
minorun365
PRO
6
530
JSX - 歴史を振り返り、⾯⽩がって、エモくなろう
pal4de
3
1k
評価の納得感を2段階高める「構造化フィードバック」
aloerina
1
280
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
910
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
GitHub's CSS Performance
jonrohan
1031
460k
We Have a Design System, Now What?
morganepeng
52
7.6k
GraphQLとの向き合い方2022年版
quramy
46
14k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
A designer walks into a library…
pauljervisheath
206
24k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
Rails Girls Zürich Keynote
gr2m
94
14k
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