SlideShare a Scribd company logo
Reactive
Programming
Dwi Randy H - iOS Engineer
Overview
● What is Reactive Programming?
○ Reactive programming is a general programming term that is focused on reacting to changes, such
as data values or events. It can and often is done imperatively. A callback,delegate is an approach
to reactive programmingdone imperatively.
● Why we need Reactive Programming
○ More loosely coupled code
○ Make it easy to manage thread
○ A lot of operators that simplify work
○ Help to solve Real-Time Complex UI
○ Multi-platform standard
Example of Reactive Programming
A spreadsheet is a great example of reactive programming: cells dependent on other cells
automatically “react” when those other cells change.
Reference: https://learning.oreilly.com/library/view/reactive-programming-with/9781491931646/ch01.html
Rx Basic Building Blocks
● Observables = Dog
● Subscribers = Child
● Operators = Process
Down
Observables
Observable are the data source/stream, then that
observer reacts to whatever item or sequence of items
the observables emits.
They can emit data, completion and also failure
Hot and Cold Observables
Cold observables don’t do
anything until someone
starts observing them
(subscribe in Rx). They only
start running when they are
consumed
Hot Observables that can
active before subscription,
when an observer subscribes
to hot observable it will get
all values in the stream that
are emitted
Cold Observable
Hot Observable (Subject)
When We Need Cold or Hot
When we need to observable to
generating new values when
someone subscribing it and the
values are also not shared among
subscribers For example when we
call the API, Getting data from
local database
When you have Observable and we want
multiple subscribers to it, and you don’t
want them to cause regenerating the
values but rather reusing existing values
For example as LiveData in MVVM iOS
Reference: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/creating.md#cold-vs-hot-observables
Operator
An operator is simply a function that performs a
specific action. It takes a value, does something
with it and then returns it
● Creating
● Transforming
● Filtering
● Combining
Operator (Creating)
● Create
Create an observable from scratch by
calling observer method programmatically
● Just
Convert an object into Observable that
emits that object
Operator (Transforming)
● Map
Transform the items emitted by an
Observable by applying a function to each
item
● FlatMap
Transform the items emitted by an
Observable into Observables, then flatten
the emissions from those into a single
Observable
Observers
Observers consumes the data stream emitted by
observables
Observers subscribe to observable using subscribeOn()
method to receive data and then the data will be received
in onNext() callback()
Observer Callback
OnNext()
The callback to receive a
valueless notification of type
complete from the Observable.
OnComplete()
The callback to receive a
valueless notification of type
complete from the Observable.
onError()
The callback to receive notifications of
type error from the Observable, with an
attached Error.
Scheduler
Scheduler are component that tells observables
and observers on which thread they should run
- subscribeOn()
Specifies on which Scheduler to
Observables should operate
- observeOn()
Specifies on which Scheduler/Thread the
Subscribers should be notified
Scheduler Types Used
- Schedulers.io()
It is used for non CPU-intensive I/O type work
including interaction with the file system, performing
network calls, database interactions. This is usually
used in subscribeOn method
- Schedulers.computation
It is used for computational or CPU-intensive work
such as resizing images, processing large data sets,
Reference: https://proandroiddev.com/understanding-rxjava-subscribeon-and-observeon-
744b0c6a41ea
- AndroidSchedulers.trampoline
This is used to executes tasks in a FIFO (First
In, First Out). This scheduler runs the code on
current thread for example for Unit Testing
- AndroidSchedulers.mainThread()
This is used to bring back the execution to the
main thread so that UI modification can be
made. This is usually used in observeOn
method.
RxBinding & RxCocoa
- Library that makes it easier to use UI Component with reactive techniques.
Reference: https://github.com/ReactiveX/RxSwift
Thank you!

More Related Content

PDF
Introduction to Spring webflux
PPTX
Reactive Programming In Java Using: Project Reactor
PPTX
Reactive programming
PPTX
Reactive programming intro
PDF
Understanding Reactive Programming
PPTX
Spring Webflux
PPT
Reactive programming with examples
PDF
Project Reactor Now and Tomorrow
Introduction to Spring webflux
Reactive Programming In Java Using: Project Reactor
Reactive programming
Reactive programming intro
Understanding Reactive Programming
Spring Webflux
Reactive programming with examples
Project Reactor Now and Tomorrow

What's hot (20)

PDF
Apache Airflow
PDF
[Webinar]: Working with Reactive Spring
PDF
Intro - Cloud Native
PDF
Presto Summit 2018 - 09 - Netflix Iceberg
PDF
Airflow for Beginners
PPTX
Microservices Part 3 Service Mesh and Kafka
PDF
Reactive Programming for Real Use Cases
PPTX
Prometheus and Grafana
PDF
Microservice Architecture Patterns, by Richard Langlois P. Eng.
PDF
Introduction to Spring WebFlux #jsug #sf_a1
PDF
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
PDF
Why Microservice
PDF
Building a fully managed stream processing platform on Flink at scale for Lin...
PDF
Keycloak Single Sign-On
PPSX
Apache Flink, AWS Kinesis, Analytics
PPTX
Introduction to microservices
PDF
Iceberg + Alluxio for Fast Data Analytics
PDF
NATS Connect Live!
PDF
Design patterns for microservice architecture
PPTX
Apache Airflow overview
Apache Airflow
[Webinar]: Working with Reactive Spring
Intro - Cloud Native
Presto Summit 2018 - 09 - Netflix Iceberg
Airflow for Beginners
Microservices Part 3 Service Mesh and Kafka
Reactive Programming for Real Use Cases
Prometheus and Grafana
Microservice Architecture Patterns, by Richard Langlois P. Eng.
Introduction to Spring WebFlux #jsug #sf_a1
MoP(MQTT on Pulsar) - a Powerful Tool for Apache Pulsar in IoT - Pulsar Summi...
Why Microservice
Building a fully managed stream processing platform on Flink at scale for Lin...
Keycloak Single Sign-On
Apache Flink, AWS Kinesis, Analytics
Introduction to microservices
Iceberg + Alluxio for Fast Data Analytics
NATS Connect Live!
Design patterns for microservice architecture
Apache Airflow overview
Ad

Similar to Introduction to Reactive programming (20)

PPTX
Rx for Android & iOS by Harin Trivedi
PDF
Introduction to reactive programming
PPTX
Reactive programming with RxAndroid
PPTX
Rxandroid
PPTX
RxAndroid
PPTX
Intro to Functional Programming with RxJava
PDF
RxJava@Android
PDF
RxJava@DAUG
PPTX
Reactive Programming on Android
PDF
RxJS - The Reactive extensions for JavaScript
PPTX
Introduction to RxJava on Android
PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
PDF
Streamlining with rx
PDF
RxJava pour Android : présentation lors du GDG Android Montréal
PPTX
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
PDF
RxSwift
PPTX
RxJava 2 Reactive extensions for the JVM
PDF
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
PDF
Reactive Programming for a demanding world: building event-driven and respons...
PDF
RxJava for Android - GDG DevFest Ukraine 2015
Rx for Android & iOS by Harin Trivedi
Introduction to reactive programming
Reactive programming with RxAndroid
Rxandroid
RxAndroid
Intro to Functional Programming with RxJava
RxJava@Android
RxJava@DAUG
Reactive Programming on Android
RxJS - The Reactive extensions for JavaScript
Introduction to RxJava on Android
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Streamlining with rx
RxJava pour Android : présentation lors du GDG Android Montréal
Samuele Resca - REACTIVE PROGRAMMING, DAMN. IT IS NOT ABOUT REACTJS - Codemot...
RxSwift
RxJava 2 Reactive extensions for the JVM
Reactive Programming in Java by Mario Fusco - Codemotion Rome 2015
Reactive Programming for a demanding world: building event-driven and respons...
RxJava for Android - GDG DevFest Ukraine 2015
Ad

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Cloud computing and distributed systems.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
KodekX | Application Modernization Development
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Cloud computing and distributed systems.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
KodekX | Application Modernization Development
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing

Introduction to Reactive programming

  • 2. Overview ● What is Reactive Programming? ○ Reactive programming is a general programming term that is focused on reacting to changes, such as data values or events. It can and often is done imperatively. A callback,delegate is an approach to reactive programmingdone imperatively. ● Why we need Reactive Programming ○ More loosely coupled code ○ Make it easy to manage thread ○ A lot of operators that simplify work ○ Help to solve Real-Time Complex UI ○ Multi-platform standard
  • 3. Example of Reactive Programming A spreadsheet is a great example of reactive programming: cells dependent on other cells automatically “react” when those other cells change. Reference: https://learning.oreilly.com/library/view/reactive-programming-with/9781491931646/ch01.html
  • 4. Rx Basic Building Blocks ● Observables = Dog ● Subscribers = Child ● Operators = Process Down
  • 5. Observables Observable are the data source/stream, then that observer reacts to whatever item or sequence of items the observables emits. They can emit data, completion and also failure
  • 6. Hot and Cold Observables Cold observables don’t do anything until someone starts observing them (subscribe in Rx). They only start running when they are consumed Hot Observables that can active before subscription, when an observer subscribes to hot observable it will get all values in the stream that are emitted
  • 9. When We Need Cold or Hot When we need to observable to generating new values when someone subscribing it and the values are also not shared among subscribers For example when we call the API, Getting data from local database When you have Observable and we want multiple subscribers to it, and you don’t want them to cause regenerating the values but rather reusing existing values For example as LiveData in MVVM iOS Reference: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/gettingstarted/creating.md#cold-vs-hot-observables
  • 10. Operator An operator is simply a function that performs a specific action. It takes a value, does something with it and then returns it ● Creating ● Transforming ● Filtering ● Combining
  • 11. Operator (Creating) ● Create Create an observable from scratch by calling observer method programmatically ● Just Convert an object into Observable that emits that object
  • 12. Operator (Transforming) ● Map Transform the items emitted by an Observable by applying a function to each item ● FlatMap Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable
  • 13. Observers Observers consumes the data stream emitted by observables Observers subscribe to observable using subscribeOn() method to receive data and then the data will be received in onNext() callback()
  • 14. Observer Callback OnNext() The callback to receive a valueless notification of type complete from the Observable. OnComplete() The callback to receive a valueless notification of type complete from the Observable. onError() The callback to receive notifications of type error from the Observable, with an attached Error.
  • 15. Scheduler Scheduler are component that tells observables and observers on which thread they should run - subscribeOn() Specifies on which Scheduler to Observables should operate - observeOn() Specifies on which Scheduler/Thread the Subscribers should be notified
  • 16. Scheduler Types Used - Schedulers.io() It is used for non CPU-intensive I/O type work including interaction with the file system, performing network calls, database interactions. This is usually used in subscribeOn method - Schedulers.computation It is used for computational or CPU-intensive work such as resizing images, processing large data sets, Reference: https://proandroiddev.com/understanding-rxjava-subscribeon-and-observeon- 744b0c6a41ea - AndroidSchedulers.trampoline This is used to executes tasks in a FIFO (First In, First Out). This scheduler runs the code on current thread for example for Unit Testing - AndroidSchedulers.mainThread() This is used to bring back the execution to the main thread so that UI modification can be made. This is usually used in observeOn method.
  • 17. RxBinding & RxCocoa - Library that makes it easier to use UI Component with reactive techniques. Reference: https://github.com/ReactiveX/RxSwift

Editor's Notes

  • #3: imperative programming is a programming paradigm that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates.
  • #4: Reactive programming adalah paradigma pemrograman yang berkaitan dengan aliran data dan juga penyebaran perubahan Ketika menggunakan reactive programming data stream akan menjadi pondasi dari aplikasi kita Events, Messages, Calls bahkan failures akan di sampaikan oleh data stream dengan reactive programming kita meng observe data stream dan melakukan reaksi ketika nilai di berikan
  • #7: https://github.com/dwirandyh/bdlproperti-android/blob/6bb087dca0f466ad82e48c56d5d21b390dca95d3/app/src/main/java/com/dwirandyh/bdlproperti/core/rxbinding/RxSearchObservable.kt