Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RxJava1からRxJava2へ
Search
Yasuhiro Shimizu
October 03, 2017
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RxJava1からRxJava2へ
Yasuhiro Shimizu
October 03, 2017
More Decks by Yasuhiro Shimizu
See All by Yasuhiro Shimizu
Jetpack Composeから始める、頑張らないVRT
yshrsmz
0
1.3k
Kotlin Multiplatform Projectを導入してみて
yshrsmz
1
1.2k
BIP39について
yshrsmz
0
220
Android Fireside Chatまとめ
yshrsmz
3
2.4k
Other Decks in Programming
See All in Programming
一参加者から『中の人』へ 〜全通PHPerがブースに立って学んだ、カンファレンスを100倍楽しむコツ〜
wp_daisuke
0
140
Webの地図
yosuke_furukawa
PRO
6
4.1k
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
4
650
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
330
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
130
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
530
Seeing Through Serverless: Observability for AWS Lambda with ADOT and CloudWatch Application Signals
seike460
PRO
1
130
Family mrubyの進捗
kishima
1
110
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
810
ソフトウェアラスタライザ
fadis
1
800
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
590
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
510
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
780
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
500
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.7k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
How Software Deployment tools have changed in the past 20 years
geshan
1
34k
Transcript
RxJava1 -> RxJava2 CA.APK - YASUHIRO SHIMIZU
ABOUT ME 清水泰博(Yasuhiro Shimizu) ▸ Android Engineer @AWA Co. Ltd.
▸ GitHub: yshrsmz ▸ Twitter: _yshrsmz Omnitweety Monotweety
MIGRATING TO RXJAVA2 今日話すこと ▸ 開発を止めずRxJava2に 徐々に移行するにはどうしたらいいか ▸ AWAの場合
MIGRATING TO RXJAVA2 今日話さないこと ▸ RxJavaとは何か ▸ RxJava1とRxJava2の違い
MIGRATING TO RXJAVA2 バージョンアップどうやる? dependencies { compile: "io.reactivex:rxjava:1.3.2" } dependencies
{ compile: "io.reactivex.rxjava2:rxjava:2.1.4" }
これはやめた方がいい
MIGRATING TO RXJAVA2 RxJava1への依存を削除するのはやめた方がいい ▸ RxJava1とRxJava2では変更点が多く、作業にも確認にも時 間がかかる ▸ つまり何度も何度もmasterの変更を取り込まなければなら ない
▸ RxJava1で書いたコードがmasterにどんどん追加されていく
RxJava2Interop を使って、 少しずつRxJava2に移行しよう
MIGRATING TO RXJAVA2 What is RxJava2Interop? ▸ https://github.com/akarnokd/RxJava2Interop ▸ RxJava1とRxJava2のReactive
Typeを相互に変換 ▸ 作: David Karnok(RxJavaのmain commiter) ▸ このライブラリを使うとステップ・バイ・ステップで RxJava2に移行できる
MIGRATING TO RXJAVA2 Usage // app/build.gradle android.packagingOptions { exclude 'META-INF/rxjava.properties'
} dependencies { compile: "io.reactivex:rxjava:1.3.2" compile: "io.reactivex.rxjava2:rxjava:2.1.4" compile: "com.github.akarnokd:rxjava2-interop:0.10.6 }
MIGRATING TO RXJAVA2 使い方(in java) RxJavaInterop.toV2Flowable(v1Observable); RxJavaInterop.toV2Maybe(v1Single); RxJavaInterop.toV1Observable(v2Publisher); // etc...
MIGRATING TO RXJAVA2 使い方(in Kotlin) fun <T> rx.Observable<T>.toV2Observable() = RxJavaInterop.toV2Observable(this)
fun <T> io.reactivex.Observable<T>.toV1Observable() = RxJavaInterop.toV1Observable(this, BackpressureStrategy.LATEST) // v1Observable.toV2Observable() // v2Observable.toV1Observable() 拡張関数を定義すると捗る
ANY REAL-LIFE EXAMPLE?
テキスト 移行の手順 ▸ 各種ライブラリの移行方法検討(Realm, SQLite, Retrofit) ▸ nullを流してるストリームをOptionalに書き換える ▸ ひたすらやっていき
MIGRATING TO RXJAVA2 Realm ▸ Realm v4.0はRxJava2をサポートする(未リリース) ▸ v3.xでは2つ選択肢がある ▸
RxJava2Interopを使う ▸ v4.0の実装を参考に自分で作る ▸ https://github.com/realm/realm-java/pull/4991 ▸ Kotlinの拡張関数使うと
テキスト SQLite ▸ 特にライブラリは使わずに実装しているので、地道に書き換 える ▸ Roomへの置き換えも進行中
MITRATING TO RXJAVA2 Retrofit ▸ RxJava2CallAdapterFactoryを使う ▸ RxJava1とRxJava2のCallAdapterは共存できる Retrofit.Builder() .baseUrl("https://api.example.com")
.addCallAdapterFactory( RxJavaCallAdapterFactory.create()) .addCallAdapterFactory( RxJava2CallAdapterFactory.create()) .build()
MIGRATING TO RXJAVA2 Architecture of AWA DbClient DbClient DbClient DbClient
DbClient ApiClient SharedPreferences Realm SQLite API Server DbClient DbClient Model DbClient DbClient UseCase DBCLIENT DBCLIENT Activity/Fragment View Domain Data
MIGRATING TO RXJAVA2 Architecture of AWA DbClient DbClient DbClient DbClient
DbClient ApiClient SharedPreferences Realm SQLite API Server DbClient DbClient Model DbClient DbClient UseCase DBCLIENT DBCLIENT Activity/Fragment View Domain Data DbClientをRxJava2化 RxJava2Interop でRxJava1に変換 Domainより上の レイヤは変更不要
MIGRATING TO RXJAVA2 Some random tips ▸ doOnDisposeではなくdoFinallyを使う ▸ https://github.com/ReactiveX/RxJava/wiki/What's-
different-in-2.0 ▸ Reactive Typeで「値がない状態」を通知したい時はOptionalを 使う ▸ Kotlinだとgojuno/koptionalがミニマムでよさそう ▸ Singleで↑の場合はMaybeを使いましょう
THANK YOU!