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
Rx Java introduction
Search
SingaSUG
July 29, 2015
Technology
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rx Java introduction
Talk from Xavier Lepretre
SingaSUG
July 29, 2015
More Decks by SingaSUG
See All by SingaSUG
Java/Spring and Node.JS side by side
singasug
0
240
Migrating to microservices (Carlos Queiroz)
singasug
0
250
Docker 101 - Mario Loriedo
singasug
0
310
Docker for Java/Spring developers
singasug
0
110
Cloud Foundry and Docker
singasug
0
250
Multi dimensional scaling with CouchBase
singasug
1
150
NoSql presentation from Clarence Tauro
singasug
2
220
Spring Websockets
singasug
0
240
migrating from JSP to AngularJS
singasug
0
2.7k
Other Decks in Technology
See All in Technology
AI活用の現在地、 ちゃんと見えてますか?/XPfest-2026
visional_engineering_and_design
0
160
GuardDuty 検知対応を DevOps Agent で効率化しようとしている話 / GuardDuty Investigations with DevOps Agent
masahirokawahara
1
330
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
250
Azure App Service / Container Apps の組み込み認証
kuniteru
0
210
Podは生きているのにGoだけが落ちる:GOGCとGOMEMLIMITで追うInvisible OOM Killの謎
tkc66buzz
0
150
Oracle Cloud Infrastructure IaaS 新機能アップデート 2026/6 - 2026/8
oracle4engineer
PRO
0
120
GoCon2026 - Open Source, Open World
sanposhiho
1
360
『止めない』を設計する — 制約の中で、事業の根幹を支える判断
hiroyaterui
0
230
AI 駆動 Terraform 開発/SRE_BizReach_MIXI_2
visional_engineering_and_design
2
1.9k
Autonomous AI Databaseサービス・アップデート(FY27)/ adb-service-update-jp-fy27
oracle4engineer
PRO
0
130
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
1
250
リージョンの壁を越える、 ちょっと変わったAWSサービスの話
falken
PRO
0
270
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Visualization
eitanlees
152
17k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
520
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
490
AI: The stuff that nobody shows you
jnunemaker
PRO
9
980
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
310
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
490
Embracing the Ebb and Flow
colly
88
5.2k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
890
Rails Girls Zürich Keynote
gr2m
96
14k
How to Ace a Technical Interview
jacobian
281
24k
Building the Perfect Custom Keyboard
takai
2
870
Transcript
RxJava Intro Functional reactive programming By Xavier Lepretre
What we want What we know
Imperative and synchronous var a = fetch(key); var b =
transform(a); var c = transformAgain(b); return process(c);
Asynchronous with callbacks fetch(key, new Callback() { void onReceived(a) {
transform(a, new Callback() { void onFinished(b) ... }); } });
Futures future = executor.submit(new Callback() { Object call() { return
doLongExecution(); } }); a = future.get();
Nice to have, workflow description When done, do that fetch(key).then(a
-> transform(a)) .then(b -> transformAgain(b)) .then(c -> process(c)) .then(d -> use(d));
Important classes
Observable<MyType> - like an object(s) pipe - no limit on
number of objects piped - also pipes Throwable - signals when no more object, completed - can have many observers, like a multicast
Observer<MyType> - will receive: - the objects - the errors
- the completed signal - can subscribe to many observables
Subscription - a handle to an observer subscribed to an
observable - call .unsubscribe() when you no longer need to receive
Action1<MyType> { void call(MyType obj); } - 1 because it
takes 1 parameter - There are Action2 … Action9
Func1<MyType, NextType> { public NextType call(MyType obj); } - 1
because it takes 1 parameter - There are Func2 … Func9
Important operations
.map(new Func1<A,B>(){}) - works on an object traveling along the
pipe - transforms from one type to another - to be used when the transformation is synchronous - example: convert
None
.doOnNext(new Action1<A>(){}) - Works on a object from the pipe
- Leaves the object unchanged - Example: save in cache, log
None
.flatMap(Func1<A, Observable<B>>) - Works on an object traveling along the
pipe - Transforms from one type to another - To be used when the transformation is asynchronous - Example: network fetch, open dialog
None
Advantages - Unsubscription handles removing callback - Method can describe
a subset of workflow
Create your own: OnSubscribe<> - Change callbacks into objects in
pipeline - Know when to call onCompleted() - subscribeOn() - Subscriptions.create() - AndroidSubscriptions. unsubscribeInUiThread
Pitfalls - Forgot to .subscribe() - subscriptionList.unsubscribe(). Do not reuse
- forgot observeOn(AndroidSchedulers. mainThread()) - callbacks may not show as used if you use retrolambda
Code Example https://github.com/xavierlepretre/rx-example
- All code shown is on client - Retrofit creates
Observables -
- workflow pieces in methods: for dialog, no need to
know next step - .onErrorResumeNext() to avoid break on less important elements - .flatMap() to show and wait for dialog - .publish() and .connect() to share Observable - SimpleAlertDialogOperator to convert a dialog into Observable