SlideShare a Scribd company logo
Reactive Programming
with JavaScript
I am Duc Pham
You can reach me at pngduc@gmail.com
Hi!
2
Audiences
3
Outline
1. Introduction to Reactive Programming
2. Reactive Extensions and RxJS
3. Showcase
4. Discussions
4
Introduction to
Reactive Programming
5
1
Events
◉ DOM events, animations
◉ Asynchronous response events
◉ Time-related events
6
Problems
7
Upcoming events
- Incoming messages/calls
- Friends online/offline
- Friend is typing
- Search for friends
- Add reactions
- Typing/Sending messages
...
Old ways
8
Reactive Programming (with
streams)
9
Streams = Observables
10
“
Reactive programming is
programming with asynchronous
data streams
11
Reactive Extension
12
2
A library that brings Reactive Programming
to many languages
Transforming events in streams
Merging, mixing several streams
Dealing with time delaying events, creating interval
Reactive Extension Features
13
Observables
Operators
Reactive Extension - Models
14
Reactive Extension - Observables
15
// From primitive data type
Rx.Observable.just(12)
// From array
Rx.Observable.from([1, 2, 3, 4])
// From interval
Rx.Observable.interval(10)
// From promise
Rx.Observable.fromPromise(promise)
// From DOM events
Rx.Observable.fromEvent(
document.getElementById('keyword'),
'keyup'
)
Reactive Extension - Operators
16
◉ map
◉ filter
◉ zip
◉ flatMap/concatMap
◉ reduce/scan
◉ debounce
◉ combineWithLatest
◉ merge
….many more
https://rxmarbles.com
Showcase
17
3
Showcases
Instant Search - Codepen
19
const source = (term) => {
const endpoint =
`https://api.gh.com/s/repos?q=${term}`;
return Rx.Observable.create(function(observer) {
fetch(endpoint)
.then(res => res.json())
.then(j => {
observer.onNext(j.items);
observer.onCompleted();
})
.catch(observer.onError);
});
};
Rx.Observable.fromEvent(el, 'keyup')
.map(e => e.target.value)
.debounce(300)
.distinctUntilChanged()
.flatMapLatest(term => source(term))
.subscribe(function(data){
self.items = data;
self.update();
});
Functional
Less is more
Concurrency made easy
Advantages of applying RxJS
Better codebases
22
Memory consumption
Long learning time
Debugging
Overuse
Disadvantages of applying RxJS
23
24
Who use ReactiveX?
Learning path
Official document
https://reactivex.io
Resources and code sample for common use-cases
https://learnrxjs.io
25
Any questions?
Thanks!
26

More Related Content

PDF
Blocks, procs && lambdas
PDF
Intro to GO (Bangkok Launchpad 2014)
PPTX
RDF Stream Processing: Let's React
PDF
Beyond Fault Tolerance with Actor Programming
PDF
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
PDF
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
PDF
Reaktive Programmierung mit den Reactive Extensions (Rx)
PDF
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...
Blocks, procs && lambdas
Intro to GO (Bangkok Launchpad 2014)
RDF Stream Processing: Let's React
Beyond Fault Tolerance with Actor Programming
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Distributed Reactive Services with Reactor & Spring - Stéphane Maldini
Reaktive Programmierung mit den Reactive Extensions (Rx)
WWX14 speech : Justin Donaldson "Promhx : Cross-platform Promises and Reactiv...

Similar to [DevDay 2019] Reactive Programming with JavaScript - By Pham Nguyen Duc, Web Developer at Agility IO (20)

PDF
Node.js Course 1 of 2 - Introduction and first steps
PDF
Learning RSocket Using RSC
PDF
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
PDF
Stream Processing with CompletableFuture and Flow in Java 9
PPTX
Solve it Differently with Reactive Programming
PDF
Go Synchronized
PDF
JAZOON'13 - Andrej Vckovski - Go synchronized
PPTX
Reactive programming intro
PDF
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
PDF
RxJava@DAUG
PPTX
Reactive programming
PDF
Reactive programming using rx java & akka actors - pdx-scala - june 2014
PPT
Advanced Operating System, Distributed Operating System
PDF
Dragoncraft Architectural Overview
PDF
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
PPT
Node.js: CAMTA Presentation
PDF
PL Lecture 01 - preliminaries
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
PDF
Reactive in Android and Beyond Rx
Node.js Course 1 of 2 - Introduction and first steps
Learning RSocket Using RSC
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
Stream Processing with CompletableFuture and Flow in Java 9
Solve it Differently with Reactive Programming
Go Synchronized
JAZOON'13 - Andrej Vckovski - Go synchronized
Reactive programming intro
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
RxJava@DAUG
Reactive programming
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Advanced Operating System, Distributed Operating System
Dragoncraft Architectural Overview
Reactive Java Robotics and IoT - IPT Presentation @ Voxxed Days 2016
Node.js: CAMTA Presentation
PL Lecture 01 - preliminaries
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne Talk 2016)
Reactive in Android and Beyond Rx
Ad

More from DevDay Da Nang (20)

PDF
[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at Wizeline
PPT
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
PDF
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
PDF
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
PDF
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
PDF
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
PPTX
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
PPTX
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
PPTX
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
PPTX
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
PPTX
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
PPTX
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
PPTX
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
PDF
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
PDF
[DevDay2019] Opportunities and challenges for human resources during the digi...
PPTX
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
PPTX
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
PPTX
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
PPTX
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
PDF
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
[DevDay2019] Lean UX - By Bryant Castro, Bryant Castro at Wizeline
[DevDay2019] Why you'll lose without UX Design - By Szilard Toth, CTO at e·pi...
[DevDay2019] Things i wish I knew when I was a 23-year-old Developer - By Chr...
[DevDay2019] Designing design teams - Christopher Nguyen, UX Manager at Wizeline
[DevDay2019] Growth Hacking - How to double the benefits of your startup with...
[DevDay2019] Collaborate or die: The designers’ guide to working with develop...
[DevDay2019] How AI is changing the future of Software Testing? - By Vui Nguy...
[DevDay2019] Hands-on Machine Learning on Google Cloud Platform - By Thanh Le...
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
[DevDay2019] Power of Test Automation and DevOps combination - One click savi...
[DevDay2019] How do I test AI models? - By Minh Hoang, Senior QA Engineer at KMS
[DevDay2019] How to quickly become a Senior Engineer - By Tran Anh Minh, CEO ...
[Devday2019] Dev start-up - By Le Trung, Founder & CEO at Hifiveplus and Edu...
[DevDay2019] Web Development In 2019 - A Practical Guide - By Hoang Nhu Vinh,...
[DevDay2019] Opportunities and challenges for human resources during the digi...
[DevDay2019] Python Machine Learning with Jupyter Notebook - By Nguyen Huu Th...
[DevDay2019] Do you dockerize? Are your containers safe? - By Pham Hong Khanh...
[DevDay2019] Develop a web application with Kubernetes - By Nguyen Xuan Phong...
[DevDay2019] Paradigm shift towards effective Scrum - By Tam Doan, Agile Coac...
[DevDay2019] JAM Stack - By Ngo Thi Ni, Web Developer at Agility IO
Ad

Recently uploaded (20)

PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
Spectral efficient network and resource selection model in 5G networks
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity

[DevDay 2019] Reactive Programming with JavaScript - By Pham Nguyen Duc, Web Developer at Agility IO