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
Python札幌 LT資料
t3tra
7
1.1k
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
5
1.5k
Canon EOS R50 V と R5 Mark II 購入でみえてきた最近のデジイチ VR180 事情、そして VR180 静止画に活路を見出すまで
karad
0
140
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
130
ZJIT: The Ruby 4 JIT Compiler / Ruby Release 30th Anniversary Party
k0kubun
1
300
AtCoder Conference 2025
shindannin
0
840
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2.1k
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
230
Pythonではじめるオープンデータ分析〜書籍の紹介と書籍で紹介しきれなかった事例の紹介〜
welliving
3
680
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
150
Cap'n Webについて
yusukebe
0
160
認証・認可の基本を学ぼう後編
kouyuume
0
260
Featured
See All Featured
AI: The stuff that nobody shows you
jnunemaker
PRO
1
37
YesSQL, Process and Tooling at Scale
rocio
174
15k
Building the Perfect Custom Keyboard
takai
1
670
New Earth Scene 8
popppiees
0
1.3k
Thoughts on Productivity
jonyablonski
73
5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
990
The Limits of Empathy - UXLibs8
cassininazir
1
200
Technical Leadership for Architectural Decision Making
baasie
0
200
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
43
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
30
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.2k
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以上で開発したい⼈ ご連絡お待ちしております