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
そのpreloadは必要?見過ごされたpreloadが技術的負債として爆発した日
mugitti9
2
3.4k
私達はmodernize packageに夢を見るか feat. go/analysis, go/ast / Go Conference 2025
kaorumuta
2
560
Go言語の特性を活かした公式MCP SDKの設計
hond0413
1
230
CSC305 Lecture 06
javiergs
PRO
0
230
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
1
270
品質ワークショップをやってみた
nealle
0
180
Flutterで分数(Fraction)を表示する方法
koukimiura
0
130
kiroとCodexで最高のSpec駆動開発を!!数時間で web3ネイティブなミニゲームを作ってみたよ!
mashharuki
0
310
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
220
Six and a half ridiculous things to do with Quarkus
hollycummins
0
170
いま中途半端なSwift 6対応をするより、Default ActorやApproachable Concurrencyを有効にしてからでいいんじゃない?
yimajo
2
420
Claude CodeによるAI駆動開発の実践 〜そこから見えてきたこれからのプログラミング〜
iriikeita
0
210
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
Why Our Code Smells
bkeepers
PRO
340
57k
The Cost Of JavaScript in 2023
addyosmani
55
9k
Reflections from 52 weeks, 52 projects
jeffersonlam
353
21k
Designing for Performance
lara
610
69k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
What's in a price? How to price your products and services
michaelherold
246
12k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
A Tale of Four Properties
chriscoyier
161
23k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
20
1.2k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
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以上で開発したい⼈ ご連絡お待ちしております