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
110
スタートアップの急成長に寄り添うOn-Call体制構築とその変遷
horimislime
3
1.5k
How we build our app with minimum 3rd party dependencies
horimislime
0
80
サポート効率を上げるためのロギング環境構築
horimislime
7
3.7k
社内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
LINEヤフー株式会社における音声言語情報処理AI研究開発@SP/SLP研究会 2024.10.22
lycorptech_jp
PRO
2
190
日経電子版におけるリアルタイムレコメンドシステム開発の事例紹介/nikkei-realtime-recommender-system
yng87
2
590
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
1
190
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
27
12k
フルカイテン株式会社 採用資料
fullkaiten
0
36k
使えそうで使われないCloudHSM
maikamibayashi
1
240
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
49k
Spring Frameworkの新標準!? ~ RestClientとHTTPインターフェース入門 ~
ogiwarat
1
170
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
0
1.1k
AWSコンテナ本出版から3年経った今、もし改めて執筆し直すなら / If I revise our container book
iselegant
15
4.1k
話題のGraphRAG、その可能性と課題を理解する
hide212131
4
1.6k
ガバメントクラウド先行事業中間報告を読み解く
sugiim
1
1.7k
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Building Your Own Lightsaber
phodgson
102
6.1k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Done Done
chrislema
181
16k
Learning to Love Humans: Emotional Interface Design
aarron
272
40k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Visualization
eitanlees
145
15k
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