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
360
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
140
スタートアップの急成長に寄り添うOn-Call体制構築とその変遷
horimislime
3
1.5k
How we build our app with minimum 3rd party dependencies
horimislime
0
82
サポート効率を上げるためのロギング環境構築
horimislime
7
3.8k
社内Swiftもくもく会成果発表
horimislime
0
110
Swift Optional Extension Tips
horimislime
1
1.4k
ios-internationalization
horimislime
2
8.8k
UI testing in XCode7
horimislime
3
750
UIテストをカジュアルに自動化 / UI Automation using Remote
horimislime
2
2.3k
Other Decks in Technology
See All in Technology
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
390
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
430
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
320
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
100
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
130
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
540
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.2k
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
50
7.2k
A Philosophy of Restraint
colly
203
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Side Projects
sachag
452
42k
Designing the Hi-DPI Web
ddemaree
280
34k
GitHub's CSS Performance
jonrohan
1030
460k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Designing Experiences People Love
moore
138
23k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
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