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

What's hot (20)

PDF
Support distributed computing and caching avec hazelcast
ENSET, Université Hassan II Casablanca
 
PPTX
React + Redux Introduction
Nikolaus Graf
 
PDF
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu
 
PDF
React
중운 박
 
PDF
Spring Framework - Core
Dzmitry Naskou
 
PPTX
Kafka presentation
Mohammed Fazuluddin
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PPTX
Introduction to React JS for beginners
Varun Raj
 
PPTX
What is Ajax technology?
JavaTpoint.Com
 
PDF
Support NodeJS avec TypeScript Express MongoDB
ENSET, Université Hassan II Casablanca
 
PDF
L'API Collector dans tous ses états
José Paumard
 
PPTX
Prometheus and Grafana
Lhouceine OUHAMZA
 
PPTX
Spring Boot and REST API
07.pallav
 
PDF
Architecture jee principe de inversion de controle et injection des dependances
ENSET, Université Hassan II Casablanca
 
PPTX
CSRF Attack and Its Prevention technique in ASP.NET MVC
Suvash Shah
 
PPT
Spring Core
Pushan Bhattacharya
 
PPTX
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Scrum Breakfast Vietnam
 
PDF
Pentesting GraphQL Applications
Neelu Tripathy
 
PDF
Mise en oeuvre des Frameworks de Machines et Deep Learning pour les Applicati...
ENSET, Université Hassan II Casablanca
 
PDF
Spring Boot & Actuators
VMware Tanzu
 
Support distributed computing and caching avec hazelcast
ENSET, Université Hassan II Casablanca
 
React + Redux Introduction
Nikolaus Graf
 
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu
 
React
중운 박
 
Spring Framework - Core
Dzmitry Naskou
 
Kafka presentation
Mohammed Fazuluddin
 
[Final] ReactJS presentation
洪 鹏发
 
Introduction to React JS for beginners
Varun Raj
 
What is Ajax technology?
JavaTpoint.Com
 
Support NodeJS avec TypeScript Express MongoDB
ENSET, Université Hassan II Casablanca
 
L'API Collector dans tous ses états
José Paumard
 
Prometheus and Grafana
Lhouceine OUHAMZA
 
Spring Boot and REST API
07.pallav
 
Architecture jee principe de inversion de controle et injection des dependances
ENSET, Université Hassan II Casablanca
 
CSRF Attack and Its Prevention technique in ASP.NET MVC
Suvash Shah
 
Spring Core
Pushan Bhattacharya
 
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Scrum Breakfast Vietnam
 
Pentesting GraphQL Applications
Neelu Tripathy
 
Mise en oeuvre des Frameworks de Machines et Deep Learning pour les Applicati...
ENSET, Université Hassan II Casablanca
 
Spring Boot & Actuators
VMware Tanzu
 

Similar to Introduction to Reactive programming (20)

PDF
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
PDF
Reactive Programming
Knoldus Inc.
 
PPTX
Introduction to RxJava on Android
Chris Arriola
 
PPTX
RxJava 2 Reactive extensions for the JVM
Netesh Kumar
 
PDF
RxJava@Android
Maxim Volgin
 
PDF
Introduction to reactive programming
Leapfrog Technology Inc.
 
PDF
Observables in Angular
Knoldus Inc.
 
PPTX
Intro to Functional Programming with RxJava
Mike Nakhimovich
 
PDF
RxSwift
Sally Ahmed
 
PPTX
Functional reactive programming
Araf Karsh Hamid
 
PDF
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Thomas Lockney
 
PPTX
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
PPTX
RxJava2 Slides
YarikS
 
PPTX
Андрій Рева, "How to build reactive java application"
Sigma Software
 
PDF
Predictable reactive state management - ngrx
Ilia Idakiev
 
PDF
Nicholas Gustilo "Clean Android: building great mobile apps"
IT Event
 
PPTX
Introduction to Redux.pptx
MohammadImran322154
 
PDF
Workflows via Event driven architecture
Milan Patel
 
PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
Angular 16 – the rise of Signals
Coding Academy
 
Reactive java - Reactive Programming + RxJava
NexThoughts Technologies
 
Reactive Programming
Knoldus Inc.
 
Introduction to RxJava on Android
Chris Arriola
 
RxJava 2 Reactive extensions for the JVM
Netesh Kumar
 
RxJava@Android
Maxim Volgin
 
Introduction to reactive programming
Leapfrog Technology Inc.
 
Observables in Angular
Knoldus Inc.
 
Intro to Functional Programming with RxJava
Mike Nakhimovich
 
RxSwift
Sally Ahmed
 
Functional reactive programming
Araf Karsh Hamid
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Thomas Lockney
 
TDC2016SP - Trilha Node.Js
tdc-globalcode
 
RxJava2 Slides
YarikS
 
Андрій Рева, "How to build reactive java application"
Sigma Software
 
Predictable reactive state management - ngrx
Ilia Idakiev
 
Nicholas Gustilo "Clean Android: building great mobile apps"
IT Event
 
Introduction to Redux.pptx
MohammadImran322154
 
Workflows via Event driven architecture
Milan Patel
 
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Angular 16 – the rise of Signals
Coding Academy
 
Ad

Recently uploaded (20)

PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Digital Circuits, important subject in CS
contactparinay1
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Ad

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