SlideShare a Scribd company logo
Reactive Programming with RxJava
Code demo available in https://github.com/mayowa-egbewunmi/RxJavaTraining
1
Presented by: Egbewunmi Mayowa
Position: Senior Software Engineer, Andela
2
TABLE OF CONTENT
⬝ Introduction to Reactive Programming
⬝ Rx Observables
⬝ Multi Threading with RxJava
⬝ Error Handling
⬝ Q & A
Introduction
3
1. Reactive programming is a paradigm where data is emitted from a
component (a source) to another component (a subscriber). This
helps us to handle asynchronous operations effectively.
2. Asynchronous means that you can execute multiple things at a time
and you don't have to finish executing the current thing in order to
move on to next one while Synchronous basically means that you
can only execute one thing at a time.
3. Examples of asynchronous tasks: click events, HTTP requests, view
lifecycle, availability notifications, changes on a variable, change
cache events, measures from a sensor, literally anything that may
change or happen at anytime.
4. Reactive Programming is not Reactive System :)
Reactive Programming Paradigm
4
Observables
Observer
TransformationOperators
1. Observables emits data streams from an action
performed
2. Operators are functions for transforming and
filtering data-stream/observable e.g filter(),
map()
3. An observer subscribes to an Observable, the
observer reacts to whatever item or sequence of
items the Observable emits.
Single
OnComplete
Observable
OnComplete
Completable
OnComplete
Flowable BackPressure
Maybe
OnComplete
OnComplete
Rx Observables
Threading in RxJava
1. If Thread is not specified in an Rx chain, the system main thread will be used
2. Schedulers.io is for I/O operations, Scheduler.computation is for performing intensive logic,
AndroidSchedulers.mainThread is for ui update
3. Do not perform I/O operations or intensive logic on the main thread
4. In Rx, subscribeOn operator determines on which thread “data stream” will be computed and emitted.
Without observeOn operator in Rx Chain, data will be observed from subscribeOn thread
5. In Rx, observeOn operator determines the thread for all the rx operators beneath it. To avoid bad behaviour,
observeOn operator should come immediately before subscribe()
6. Should the creator of an observable add the subscribeOn thread or the caller of the observable?
Error Handling In RxJava
1. Unexpected exception thrown by an Observable or its Operator
can be leaked to the Observer’s onError method but should not be swallowed but rethrown
2. Expected exception thrown by an Observable or its Operator
should not be leaked to the Observer’s onError method
3. An unexpected exception is an error whose source is unknown while an expected
exception is an error whose source is known to be from an external factor
4. RxJava Toolkits provide operators for handling exception/error
5. Sometimes we want to log an exception after the data stream has been observed/consumed,
where in the rx flow will this be done?
Summary
In today’s demo, we looked at how to create Rx Observables and how to apply them to
different real world scenarios. We also talked about how to perform concurrent operations
with multi threading. And finally, we discussed error handling in rxJava.
There is more!
1. Chaining, Transforming and Combining Observables
2. Rx Subjects
3. ConnectableObservable
4. Unit Testing
8
Q & A
9

More Related Content

PDF
Sperasoft Talks: RxJava Functional Reactive Programming on Android
PDF
[FullStack NYC 2019] Effective Unit Tests for JavaScript
PPTX
Storm (Distribute Stream Processing System)
PPT
Defensive programming
PPTX
Resource Leaks in Java
PPTX
Concurrency Errors in Java
PDF
Best practices for unit testing RxJava
PPT
Specs2 3.0
Sperasoft Talks: RxJava Functional Reactive Programming on Android
[FullStack NYC 2019] Effective Unit Tests for JavaScript
Storm (Distribute Stream Processing System)
Defensive programming
Resource Leaks in Java
Concurrency Errors in Java
Best practices for unit testing RxJava
Specs2 3.0

What's hot (20)

PDF
Observability in Java: Getting Started with OpenTelemetry
PDF
Defencive programming
PPT
Specs2 3.4
PDF
RxSwift
PDF
Scala laboratory: Globus. iteration #3
PDF
Java input Scanner
ODP
Rtt preso
PDF
Java Repetiotion Statements
PPTX
Angular 2.0 change detection
PDF
TestWorks Conf Performance testing made easy with gatling - Guillaume Corré
PDF
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
PDF
Checking Bitcoin
PDF
Unit Testing your React / Redux app (@BucharestJS)
PDF
From Elixir to Akka (and back) - ElixirConf Mx 2017
PDF
Unit Testing Lightning Components with Jasmine
DOC
Ecet 405 Enhance teaching-snaptutorial.com
PPTX
OpenTelemetry For Architects
PPTX
Action filter
DOCX
ECET 405 Education Organization - snaptutorial.com
PPTX
OSS Java Analysis - What You Might Be Missing
Observability in Java: Getting Started with OpenTelemetry
Defencive programming
Specs2 3.4
RxSwift
Scala laboratory: Globus. iteration #3
Java input Scanner
Rtt preso
Java Repetiotion Statements
Angular 2.0 change detection
TestWorks Conf Performance testing made easy with gatling - Guillaume Corré
prohuddle-utPLSQL v3 - Ultimate unit testing framework for Oracle
Checking Bitcoin
Unit Testing your React / Redux app (@BucharestJS)
From Elixir to Akka (and back) - ElixirConf Mx 2017
Unit Testing Lightning Components with Jasmine
Ecet 405 Enhance teaching-snaptutorial.com
OpenTelemetry For Architects
Action filter
ECET 405 Education Organization - snaptutorial.com
OSS Java Analysis - What You Might Be Missing
Ad

Similar to Rx java workshop (20)

PPTX
Introduction to RxJava on Android
PDF
How to Think in RxJava Before Reacting
PPTX
Intro to Functional Programming with RxJava
PDF
The Mayans Lost Guide to RxJava on Android
PDF
RxJava@DAUG
PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
PDF
RxJava@Android
PPTX
Introduction to Reactive programming
PPTX
Reactive Programming on Android - RxAndroid - RxJava
PDF
RxJava for Android - GDG DevFest Ukraine 2015
PDF
RxJava - introduction & design
PPTX
Reactive programming with RxAndroid
PPTX
Rxandroid
PPTX
RxAndroid
PPTX
Reactive Programming on Android
PDF
RxJava pour Android : présentation lors du GDG Android Montréal
PDF
My Gentle Introduction to RxJS
PDF
Streamlining with rx
PDF
Reactive java - Reactive Programming + RxJava
PDF
Intro to Rx Java
Introduction to RxJava on Android
How to Think in RxJava Before Reacting
Intro to Functional Programming with RxJava
The Mayans Lost Guide to RxJava on Android
RxJava@DAUG
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
RxJava@Android
Introduction to Reactive programming
Reactive Programming on Android - RxAndroid - RxJava
RxJava for Android - GDG DevFest Ukraine 2015
RxJava - introduction & design
Reactive programming with RxAndroid
Rxandroid
RxAndroid
Reactive Programming on Android
RxJava pour Android : présentation lors du GDG Android Montréal
My Gentle Introduction to RxJS
Streamlining with rx
Reactive java - Reactive Programming + RxJava
Intro to Rx Java
Ad

Recently uploaded (20)

PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
Introduction to Artificial Intelligence
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
medical staffing services at VALiNTRY
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
Understanding Forklifts - TECH EHS Solution
DOCX
Looking for a Tableau Alternative Try Helical Insight Open Source BI Platform...
PPTX
Safe Confined Space Entry Monitoring_ Singapore Experts.pptx
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
L1 - Introduction to python Backend.pptx
PPTX
ai tools demonstartion for schools and inter college
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Mini project ppt template for panimalar Engineering college
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPT
Introduction Database Management System for Course Database
Materi-Enum-and-Record-Data-Type (1).pptx
Introduction to Artificial Intelligence
ManageIQ - Sprint 268 Review - Slide Deck
medical staffing services at VALiNTRY
The Five Best AI Cover Tools in 2025.docx
Understanding Forklifts - TECH EHS Solution
Looking for a Tableau Alternative Try Helical Insight Open Source BI Platform...
Safe Confined Space Entry Monitoring_ Singapore Experts.pptx
A REACT POMODORO TIMER WEB APPLICATION.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Softaken Excel to vCard Converter Software.pdf
L1 - Introduction to python Backend.pptx
ai tools demonstartion for schools and inter college
Essential Infomation Tech presentation.pptx
Mini project ppt template for panimalar Engineering college
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Upgrade and Innovation Strategies for SAP ERP Customers
Introduction Database Management System for Course Database

Rx java workshop

  • 1. Reactive Programming with RxJava Code demo available in https://github.com/mayowa-egbewunmi/RxJavaTraining 1 Presented by: Egbewunmi Mayowa Position: Senior Software Engineer, Andela
  • 2. 2 TABLE OF CONTENT ⬝ Introduction to Reactive Programming ⬝ Rx Observables ⬝ Multi Threading with RxJava ⬝ Error Handling ⬝ Q & A
  • 3. Introduction 3 1. Reactive programming is a paradigm where data is emitted from a component (a source) to another component (a subscriber). This helps us to handle asynchronous operations effectively. 2. Asynchronous means that you can execute multiple things at a time and you don't have to finish executing the current thing in order to move on to next one while Synchronous basically means that you can only execute one thing at a time. 3. Examples of asynchronous tasks: click events, HTTP requests, view lifecycle, availability notifications, changes on a variable, change cache events, measures from a sensor, literally anything that may change or happen at anytime. 4. Reactive Programming is not Reactive System :)
  • 4. Reactive Programming Paradigm 4 Observables Observer TransformationOperators 1. Observables emits data streams from an action performed 2. Operators are functions for transforming and filtering data-stream/observable e.g filter(), map() 3. An observer subscribes to an Observable, the observer reacts to whatever item or sequence of items the Observable emits.
  • 6. Threading in RxJava 1. If Thread is not specified in an Rx chain, the system main thread will be used 2. Schedulers.io is for I/O operations, Scheduler.computation is for performing intensive logic, AndroidSchedulers.mainThread is for ui update 3. Do not perform I/O operations or intensive logic on the main thread 4. In Rx, subscribeOn operator determines on which thread “data stream” will be computed and emitted. Without observeOn operator in Rx Chain, data will be observed from subscribeOn thread 5. In Rx, observeOn operator determines the thread for all the rx operators beneath it. To avoid bad behaviour, observeOn operator should come immediately before subscribe() 6. Should the creator of an observable add the subscribeOn thread or the caller of the observable?
  • 7. Error Handling In RxJava 1. Unexpected exception thrown by an Observable or its Operator can be leaked to the Observer’s onError method but should not be swallowed but rethrown 2. Expected exception thrown by an Observable or its Operator should not be leaked to the Observer’s onError method 3. An unexpected exception is an error whose source is unknown while an expected exception is an error whose source is known to be from an external factor 4. RxJava Toolkits provide operators for handling exception/error 5. Sometimes we want to log an exception after the data stream has been observed/consumed, where in the rx flow will this be done?
  • 8. Summary In today’s demo, we looked at how to create Rx Observables and how to apply them to different real world scenarios. We also talked about how to perform concurrent operations with multi threading. And finally, we discussed error handling in rxJava. There is more! 1. Chaining, Transforming and Combining Observables 2. Rx Subjects 3. ConnectableObservable 4. Unit Testing 8