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
Project Reactor Now and Tomorrow
PPTX
Reactive Programming In Java Using: Project Reactor
PDF
RxJS Evolved
PPTX
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
PPTX
Angular
PPTX
Reactive programming
PPTX
Spring Webflux
PDF
Understanding Reactive Programming
Project Reactor Now and Tomorrow
Reactive Programming In Java Using: Project Reactor
RxJS Evolved
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Angular
Reactive programming
Spring Webflux
Understanding Reactive Programming

What's hot (20)

PDF
Java11 New Features
PDF
Migrating Oracle database to PostgreSQL
PDF
Introduction to Spring WebFlux #jsug #sf_a1
PDF
Angular Observables & RxJS Introduction
PDF
Introduction to Spring webflux
PPTX
Spring tools4
PDF
PDF
Microservice With Spring Boot and Spring Cloud
PDF
これからSpringを使う開発者が知っておくべきこと
PPTX
Angular 2
PDF
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
PDF
Spring Boot Actuator 2.0 & Micrometer
PPTX
Java 8 Lambda and Streams
PDF
Spring Bootをはじめる時にやるべき10のこと
PDF
Apache Kafka Architecture & Fundamentals Explained
PDF
RxJS - The Basics & The Future
PDF
Apache Pulsar Development 101 with Python
PDF
いまさらながらの Windows Workflow 入門
PPTX
PDF
Introduction to Apache Flink
Java11 New Features
Migrating Oracle database to PostgreSQL
Introduction to Spring WebFlux #jsug #sf_a1
Angular Observables & RxJS Introduction
Introduction to Spring webflux
Spring tools4
Microservice With Spring Boot and Spring Cloud
これからSpringを使う開発者が知っておくべきこと
Angular 2
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Spring Boot Actuator 2.0 & Micrometer
Java 8 Lambda and Streams
Spring Bootをはじめる時にやるべき10のこと
Apache Kafka Architecture & Fundamentals Explained
RxJS - The Basics & The Future
Apache Pulsar Development 101 with Python
いまさらながらの Windows Workflow 入門
Introduction to Apache Flink
Ad

Similar to Introduction to Reactive programming (20)

PDF
Reactive java - Reactive Programming + RxJava
PDF
Reactive Programming
PPTX
Introduction to RxJava on Android
PPTX
RxJava 2 Reactive extensions for the JVM
PDF
RxJava@Android
PDF
Introduction to reactive programming
PDF
Observables in Angular
PPTX
Intro to Functional Programming with RxJava
PDF
RxSwift
PPTX
Functional reactive programming
PDF
Reactive programming using rx java & akka actors - pdx-scala - june 2014
PPTX
TDC2016SP - Trilha Node.Js
PPTX
RxJava2 Slides
PPTX
Андрій Рева, "How to build reactive java application"
PDF
Predictable reactive state management - ngrx
PDF
Nicholas Gustilo "Clean Android: building great mobile apps"
PPTX
Introduction to Redux.pptx
PDF
Workflows via Event driven architecture
PPTX
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
PDF
Angular 16 – the rise of Signals
Reactive java - Reactive Programming + RxJava
Reactive Programming
Introduction to RxJava on Android
RxJava 2 Reactive extensions for the JVM
RxJava@Android
Introduction to reactive programming
Observables in Angular
Intro to Functional Programming with RxJava
RxSwift
Functional reactive programming
Reactive programming using rx java & akka actors - pdx-scala - june 2014
TDC2016SP - Trilha Node.Js
RxJava2 Slides
Андрій Рева, "How to build reactive java application"
Predictable reactive state management - ngrx
Nicholas Gustilo "Clean Android: building great mobile apps"
Introduction to Redux.pptx
Workflows via Event driven architecture
Javantura v3 - Going Reactive with RxJava – Hrvoje Crnjak
Angular 16 – the rise of Signals
Ad

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
1. Introduction to Computer Programming.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Approach and Philosophy of On baking technology
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
1. Introduction to Computer Programming.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
TLE Review Electricity (Electricity).pptx
Approach and Philosophy of On baking technology
A comparative study of natural language inference in Swahili using monolingua...
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
MIND Revenue Release Quarter 2 2025 Press Release
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Tartificialntelligence_presentation.pptx
Unlocking AI with Model Context Protocol (MCP)
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
A Presentation on Artificial Intelligence
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