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
RxJava: Which thread is running
Search
Samuel Huang
December 27, 2018
Programming
1
230
RxJava: Which thread is running
Android Taipei - Lightning Talk
Samuel Huang
December 27, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
モテるデスク環境
mozumasu
3
1.4k
Amazon Verified Permissions実践入門 〜Cedar活用とAppSync導入事例/Practical Introduction to Amazon Verified Permissions
fossamagna
2
110
TFLintカスタムプラグインで始める Terraformコード品質管理
bells17
2
500
Pythonに漸進的に型をつける
nealle
1
140
SwiftDataを使って10万件のデータを読み書きする
akidon0000
0
250
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1.3k
CSC509 Lecture 08
javiergs
PRO
0
270
三者三様 宣言的UI
kkagurazaka
0
310
Amazon ECS Managed Instances が リリースされた!キャッチアップしよう!! / Let's catch up Amazon ECS Managed Instances
cocoeyes02
0
110
Webサーバーサイド言語としてのRustについて
kouyuume
1
5k
Module Proxyのマニアックな話 / Niche Topics in Module Proxy
kuro_kurorrr
0
200
マンガアプリViewerの大画面対応を考える
kk__777
0
430
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Become a Pro
speakerdeck
PRO
29
5.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
jQuery: Nuts, Bolts and Bling
dougneiner
65
7.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
2
200
Context Engineering - Making Every Token Count
addyosmani
8
320
Transcript
Private & Confidential RxJava: Which thread is running Samuel Huang
Private & Confidential 下載與處理資料的執行緒
Private & Confidential SubscribeOn
Private & Confidential ObserveOn
Private & Confidential taskSynchronizedObservable() .map(processData()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(subscribeOnNext());
Private & Confidential taskNetworkObservable() .map(processData()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(subscribeOnNext());
Private & Confidential SubscribeOn 指定 observable 工作的執行緒 但通知observer(onNext)的執行緒不一定相同
Private & Confidential private Observable<Void> taskNetworkObservable() { return Observable.create(emitter ->
{ runOnUiThread(() -> { emitter.onNext(null); emitter.onCompleted(); }); }, Emitter.BackpressureMode.NONE); }
Private & Confidential taskNetworkObservable() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .map(processData()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(subscribeOnNext());
Private & Confidential 使用ObserveOn確保 observer(onNext)在特定執行緒呼叫
Private & Confidential Thank you