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
220
RxJava: Which thread is running
Android Taipei - Lightning Talk
Samuel Huang
December 27, 2018
Tweet
Share
Other Decks in Programming
See All in Programming
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
250
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
4
2.1k
デザインパターンで理解するLLMエージェントの作り方 / How to develop an LLM agent using agentic design patterns
rkaga
6
510
Remix on Hono on Cloudflare Workers
yusukebe
1
310
距離関数を極める! / SESSIONS 2024
gam0022
0
300
Quine, Polyglot, 良いコード
qnighy
4
650
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
subpath importsで始めるモック生活
10tera
0
320
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
みんなでプロポーザルを書いてみた
yuriko1211
0
280
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
Docker and Python
trallard
40
3.1k
Into the Great Unknown - MozCon
thekraken
32
1.5k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Gamification - CAS2011
davidbonilla
80
5k
Faster Mobile Websites
deanohume
305
30k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
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