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
Swift 2.0でRxSwift、ReactKit、ReactiveCocoaを使ってみた
Search
Shinichiro Oba
October 14, 2015
Programming
10
5k
Swift 2.0でRxSwift、ReactKit、ReactiveCocoaを使ってみた
potatotips #22で発表した資料の加筆修正版です。
http://connpass.com/event/20240/
Shinichiro Oba
October 14, 2015
Tweet
Share
More Decks by Shinichiro Oba
See All by Shinichiro Oba
サーバサイドエンジニアと効率よく開発するためにやっていること
bricklife
8
2.2k
アッテ開発の技術:Swift と RxSwift
bricklife
19
17k
RxSwiftのobserveOnとsubscribeOnを理解する
bricklife
20
7.5k
ReactiveCocoaのゆるい紹介とメルカリでの活用事例
bricklife
3
3.8k
Apple Pay対応のやりかた
bricklife
1
25k
iOS版グローバル対応の罠と技
bricklife
8
24k
Other Decks in Programming
See All in Programming
Putting The Genie in the Bottle - A Crash Course on running LLMs on Android
iurysza
0
140
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
280
Vue・React マルチプロダクト開発を支える Vite
andpad
0
110
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.3k
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
AI時代のUIはどこへ行く?
yusukebe
18
8.9k
rage against annotate_predecessor
junk0612
0
170
旅行プランAIエージェント開発の裏側
ippo012
2
910
為你自己學 Python - 冷知識篇
eddie
1
350
Reading Rails 1.0 Source Code
okuramasafumi
0
240
チームのテスト力を鍛える
goyoki
3
170
概念モデル→論理モデルで気をつけていること
sunnyone
2
230
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
77
6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Optimizing for Happiness
mojombo
379
70k
GraphQLとの向き合い方2022年版
quramy
49
14k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Site-Speed That Sticks
csswizardry
10
820
The World Runs on Bad Software
bkeepers
PRO
70
11k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Balancing Empowerment & Direction
lara
3
620
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
Transcript
Swift 2.0で RxSwift、ReactKit、 ReactiveCocoaを使ってみた 株式会社メルカリ iOSエンジニア ⼤庭慎⼀郎
⾃⼰紹介 ⼤庭 慎⼀郎 (ooba / bricklife) 株式会社メルカリ 2013年4⽉⼊社 「メルカリ」iOS版を開発
メルカリとは? いわゆる「フリマアプリ」 2013年7⽉ JP版リリース 2014年8⽉ US版リリース
Swift 2.0で リアクティブプログラミング
選択肢 RxSwift ReactKit ReactiveCocoa etc..
RxSwift ReactiveXによる正統派Rx RxCocoaと⼀緒に提供されている Swift 2.0対応版は2.0。現時点でプレリリース版のみ https://github.com/ReactiveX/RxSwift/tree/ 2.0.0-alpha.4
ReactKit LINEの稲⾒さん作。Swift初期からある 同じ作者のSwiftTaskと合わせて使う Swift 2.0対応版が正式リリースされている https://github.com/ReactKit/ReactKit
ReactiveCocoa Objective-C時代からある⽼舗 Swift 2.0対応版は4.0。現時点でプレリリース版のみ https://github.com/ReactiveCocoa/ ReactiveCocoa/tree/v4.0-alpha.1
公式なドキュメントと サンプル
RxSwift ドキュメント、サンプル ともにリポジトリの中に 含まれる。結構豊富
ReactKit ドキュメントは最低限。 サンプルは専⽤のリポジ トリがあって結構豊富 https://github.com/ ReactKit/ ReactKitCatalog
ReactiveCocoa ドキュメントは多めだが、サンプルはなし 現状README.mdのコードもコンパイル通らない… つらい…
実際に使ってみた
やってみたこと データバインディング(プロパティ⇔UI) APIアクセスのストリーム化 インクリメンタルサーチ
データバインディング
Swiftでのプロパティ更新監視 純粋なSwiftのクラスではKVOができなくなった リアクティブプログラミングのライブラリでは各⾃で 更新監視できる仕組みを⽤意している ※ NSObjectのサブクラスでdynamicなプロパティな らKVOが動く
RxSwift KVOの代わりにVariableを使う
ReactKit KVOに依存
ReactiveCocoa KVOの代わりにMutablePropertyを使う
古き良きReactiveCocoa プロパティの変更をテキストフィールドに⾃動反映 テキストフィールドの変更をプロパティに⾃動反映 RAC(self.accountNumberTextField, text) = RACObserve(self.viewModel, accountNumber); RAC(self, inputText)
= textField.rac_textSignal;
APIアクセスのストリーム化 with APIKit
RxSwift
ReactKit
ReactiveCocoa
インクリメンタルサーチ
RxSwift
ReactKit
ReactiveCocoa
他にも試したいこと プロミス デリゲートメソッドコールのストリーム化 通知のストリーム化 MVVM etc..
どれを使えばいいか どれも⻑所短所があって選ぶの難しい 機能や安定性、学習コストを考えると現時点では RxSwiftか? データバインディングはSwiftBondなどを使う選択肢 もあり
組んでみたコード 整理してGitHubで公開予定 公開次第、資料アップデートします
ありがとうございました メルカリ新規事業でメンバー⼤募集中! https://www.wantedly.com/projects/29699 Swift 2.0+iOS 8以上で開発したい⼈ ご連絡お待ちしております