SlideShare a Scribd company logo
RxJS
The Basics & The Future
What is ?
Push based primitive in JavaScript
@ladyleet
RxJS
Push based primitive in JavaScript
Ref implementation for TC39 Observable proposal
@ladyleet
What is ?RxJS
Push based primitive in JavaScript
Domain specific language that sits on top of JS
Ref implementation for TC39 Observable proposal
@ladyleet
What is ?RxJS
Push based primitive in JavaScript
Domain specific language that sits on top of JS
Ref implementation for TC39 Observable proposal
Only external dependency to Angular (2x)
@ladyleet
What is ?RxJS
Push based primitive in JavaScript
Domain specific language that sits on top of JS
Ref implementation for TC39 Observable proposal
Easy to chain together complex interactions
@ladyleet
Only external dependency to Angular (2x)
What is ?RxJS
@ladyleet
RxJS - 2 Major Components
Observables & Observers
@ladyleet
RxJS - 2 Major Components
Observables & Observers
Observables give data and observers receive data
@ladyleet
RxJS - 2 Major Components
Observables & Observers
Observables are just functions in JavaScript - they don’t do
anything until you subscribe to them.
Observables give data and observers receive data
@ladyleet
RxJS - 2 Major Components
Observables & Observers
Observables are just functions in JavaScript - they don’t do
anything until you subscribe to them.
Observables are always observed by observers
Observables give data and observers receive data
@ladyleet
RxJS - 2 Major Components
Observables & Observers
Observables are just functions in JavaScript - they don’t do
anything until you subscribe to them.
Observables are always observed by observers
Subscribing to an Observable sets up a chain of observation
using observers.
Observables give data and observers receive data
Authors
Ben Lesh, RxJS5+Matt Podwysocki, RxJS 4
@ladyleet
RxJS
is used in big cos
@ladyleet
RxJS
@ladyleet
Let me tell you an story
@ladyleet
“Ben, teach me RxJS!”
@ladyleet
“Sure!”
@ladyleet
“RxJS Blah blah blah!”
@ladyleet
“RxJS Blah bl…uh oh…”
@ladyleet
@ladyleet
Learning RxJS Be Like...
Couldn’t find the right docs!
@ladyleet
What do these operators even do?
Learning RxJS Be Like...
@ladyleet
How do I wrap APIs in Observables?
Learning RxJS Be Like...
@ladyleet
Oops, I forgot to subscribe. (╯°□°)╯︵ ┻━┻
Learning RxJS Be Like...
@ladyleet
@ladyleet
Wow, I get it!
I love RxJS!
TRACY LEE | @ladyleet
SPEAKER & GOOGLE DEVELOPER EXPERT
DEV - ANGULAR, EMBER, REACT, RXJS
TECH WRITER & PODCASTER
THIS DOT MEDIA / LABS
MENTOR
Learning & Using RxJS
•
• Best practices for importing and using RxJS
• How to choose operators and find
documentation
• How to avoid unwanted subscriptions
• How to wrap an API
• The benefits of “same-shapedness”
• What’s coming for RxJS 6 and 7
How to create an Observable
@ladyleet
const x = new (observer => {
observer.next(‘hi’);
observer.complete();
});
How to create an Observable
Observable
@ladyleet
Many other creation methodsObservable
Observable.fromEvent
Observable.to
Observable.from
Use the
Observable
constructor
@ladyleet
Let’s build an app!
(It’s a pun app)
@ladyleet
Versions
Angular 4.2.5
Angular-CLI 1.2.0
RxJS 5.4.1
Angular Material 2.0.0-beta.7
@ladyleet
RxJS - The Basics & The Future
RxJS - The Basics & The Future
Lookahead Search
The Idiomatic RxJS Example
@ladyleet
Add an <input> to your component’s template.
Getting Observable of Text Changes from Input
@ladyleet
Use Subject as an event handler in input event.
@ladyleet
Getting Observable of Text Changes from Input
Use a template reference variable to get the text value.
@ladyleet
Getting Observable of Text Changes from Input
Using the next method to get an Observable of values.
@ladyleet
Getting Observable of Text Changes from Input
Import Subject from RxJS
@ladyleet
Getting Observable of Text Changes from Input
Add the Subject to your component class
@ladyleet
Getting Observable of Text Changes from Input
• Subjects are Observables
• Subjects are Observers (with next, error and complete)
• Allow us to push values by calling `subject$.next(value)`
• Have all operators on them any observable would
@ladyleet
On the Subject of Subjects
Importing RxJS
… this is where a lot of people make a mistake.
@ladyleet
MISTAKE: Importing ALL of RxJS
@ladyleet
Include Just What You Need
@ladyleet
Back to Our Pun App
We have an Observable of text input changes - keywordInputChange$
… give us the puns we’re looking for!
@ladyleet
To Get Our Data, We’ve Created “PunService”
@ladyleet
PunService Uses Http From @angular/http
@ladyleet
Take Observable of Textbox Changes and
Get a List of Suggested Keywords
@ladyleet
switchMap
Converts the value to a new Observable, then switches to that Observable
(unsubscribing from any previous ones it might have made)
@ladyleet
Operators: Why switchMap?
http://reactivex.io/rxjs
@ladyleet
Writing Suggested Keywords to the View
@ladyleet
Get List of Puns from List of Keywords
@ladyleet
Displaying Puns
@ladyleet
Let’s Share keyword$
@ladyleet
@ladyleet
Same Shaped-ness
Let’s add another data source!
@ladyleet
Web Speech API
https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API
@ladyleet
Wrap an API in an Observable
@ladyleet
Wrap an API in an Observable
@ladyleet
@ladyleet
Wrap an API in an Observable
An Angular Service
• Injectable
• Actually use all results
• Add error handling
@ladyleet
Add Button to Trigger Speech Recognition
@ladyleet
Pump Clicks through a Subject
@ladyleet
Inject SpeechService
@ladyleet
switchMap Clicks into Speech Recognition
@ladyleet
Merge Typed Keyword Suggestions With Spoken Ones
@ladyleet
@ladyleet
Learning & Using RxJS
•
• Best practices for importing and using RxJS
• How to choose operators and find
documentation
• How to avoid unwanted subscriptions
• How to wrap an API
• The benefits of “same-shapedness”
•
How to create an Observable
@ladyleet
What’s Next for RxJS 6 & 7?
What’s Next for RxJS 6 & 7?
@ladyleet
T-Rex => RxJS 6/7
@ladyleet
~30kb => ~3kb
(minified, bundled, and gzipped)
How did it get so small?
@ladyleet
• Implemented a lot of operators in terms of other operators
• Turn operators into one line vs 40-50 lines of code
• Ex. reduce operator is just scan and take last
• Ex. toArray is just a specialty of reduce
Patch Operators vs Lettable Operators
@ladyleet
• Patch operators
• import ‘rx/add/operator/map’
• Libraries and code breaking
• Add operators on to the
prototype
• No tree shaking
• Lettable operators
• aka operator functions
• Higher order functions
• Yay tree shaking
• Yay functional programming
Lots more to come…
@ladyleet
Resources
https://github.com/ladyleet/rxjs-test
http://reactivex.io/rxjs
https://developer.mozilla.org/en-US/docs/Web/API/
Web_Speech_API
https://cloud.google.com/vision/
@ladyleet
Thank You!
@ladyleet

More Related Content

What's hot (20)

PDF
Java 8 lambda expressions
Logan Chien
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PDF
REST APIs with Spring
Joshua Long
 
PPTX
JavaScript Event Loop
Designveloper
 
PDF
REST API and CRUD
Prem Sanil
 
PDF
우아한 모노리스
Arawn Park
 
PDF
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
PPTX
Spring Boot and REST API
07.pallav
 
PPTX
Presentation1.pptx
PradeepDyavannanavar
 
PPTX
Reactjs
Mallikarjuna G D
 
PPTX
Build RESTful API Using Express JS
Cakra Danu Sedayu
 
PDF
Angular 2 observables
Geoffrey Filippi
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPTX
Fetch API Talk
Chiamaka Nwolisa
 
PPTX
Rxjs ngvikings
Christoffer Noring
 
PPTX
Introduction to React JS
Lohith Goudagere Nagaraj
 
PDF
WebAssembly Overview
Alexandr Skachkov
 
PPTX
Functional programming with Java 8
LivePerson
 
PDF
Persistent Storage with Containers with Kubernetes & OpenShift
Red Hat Events
 
PPTX
REST API 설계
Terry Cho
 
Java 8 lambda expressions
Logan Chien
 
TypeScript for Java Developers
Yakov Fain
 
REST APIs with Spring
Joshua Long
 
JavaScript Event Loop
Designveloper
 
REST API and CRUD
Prem Sanil
 
우아한 모노리스
Arawn Park
 
ES2015 / ES6: Basics of modern Javascript
Wojciech Dzikowski
 
Spring Boot and REST API
07.pallav
 
Presentation1.pptx
PradeepDyavannanavar
 
Build RESTful API Using Express JS
Cakra Danu Sedayu
 
Angular 2 observables
Geoffrey Filippi
 
TypeScript - An Introduction
NexThoughts Technologies
 
Fetch API Talk
Chiamaka Nwolisa
 
Rxjs ngvikings
Christoffer Noring
 
Introduction to React JS
Lohith Goudagere Nagaraj
 
WebAssembly Overview
Alexandr Skachkov
 
Functional programming with Java 8
LivePerson
 
Persistent Storage with Containers with Kubernetes & OpenShift
Red Hat Events
 
REST API 설계
Terry Cho
 

Viewers also liked (7)

PDF
'The History of Metrics According to me' by Stephen Day
Docker, Inc.
 
PDF
The Power of RxJS in Nativescript + Angular
Tracy Lee
 
PDF
RxJS: A Beginner & Expert's Perspective - ng-conf 2017
Tracy Lee
 
PPTX
RxJs
Akila Iroshan
 
PDF
You will learn RxJS in 2017
名辰 洪
 
PDF
如何「畫圖」寫測試 - RxJS Marble Test
名辰 洪
 
PPTX
RxJS and Reactive Programming - Modern Web UI - May 2015
Ben Lesh
 
'The History of Metrics According to me' by Stephen Day
Docker, Inc.
 
The Power of RxJS in Nativescript + Angular
Tracy Lee
 
RxJS: A Beginner & Expert's Perspective - ng-conf 2017
Tracy Lee
 
You will learn RxJS in 2017
名辰 洪
 
如何「畫圖」寫測試 - RxJS Marble Test
名辰 洪
 
RxJS and Reactive Programming - Modern Web UI - May 2015
Ben Lesh
 
Ad

Similar to RxJS - The Basics & The Future (20)

PDF
RxJS101 - What you need to know to get started with RxJS tomorrow
Viliam Elischer
 
PDF
Angular Advanced Workshop (+ Challenges)
Georgios Kaleadis
 
PDF
Observables in Angular
Knoldus Inc.
 
PDF
My Gentle Introduction to RxJS
Mattia Occhiuto
 
PDF
Streams, Streams Everywhere! An Introduction to Rx
Andrzej Sitek
 
PPTX
Rxjs marble-testing
Christoffer Noring
 
PPTX
Workshop introduction-to-rxjs
KristinaBistrickiene1
 
PDF
RxJava pour Android : présentation lors du GDG Android Montréal
Sidereo
 
PPTX
RxJS In-Depth - AngularConnect 2015
Ben Lesh
 
PDF
RxJava@DAUG
Maxim Volgin
 
PPTX
Functional Reactive Programming (FRP): Working with RxJS
Oswald Campesato
 
PPTX
Rxjs swetugg
Christoffer Noring
 
PDF
RxJava - introduction & design
allegro.tech
 
PDF
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
GeeksLab Odessa
 
PDF
rx.js make async programming simpler
Alexander Mostovenko
 
PDF
Reactive programming and RxJS
Ravi Mone
 
PDF
DZone_RC_RxJS
Luis Atencio
 
PDF
Rxjs kyivjs 2015
Alexander Mostovenko
 
PPTX
Introduction to RxJava on Android
Chris Arriola
 
PPTX
Angular2 rxjs
Christoffer Noring
 
RxJS101 - What you need to know to get started with RxJS tomorrow
Viliam Elischer
 
Angular Advanced Workshop (+ Challenges)
Georgios Kaleadis
 
Observables in Angular
Knoldus Inc.
 
My Gentle Introduction to RxJS
Mattia Occhiuto
 
Streams, Streams Everywhere! An Introduction to Rx
Andrzej Sitek
 
Rxjs marble-testing
Christoffer Noring
 
Workshop introduction-to-rxjs
KristinaBistrickiene1
 
RxJava pour Android : présentation lors du GDG Android Montréal
Sidereo
 
RxJS In-Depth - AngularConnect 2015
Ben Lesh
 
RxJava@DAUG
Maxim Volgin
 
Functional Reactive Programming (FRP): Working with RxJS
Oswald Campesato
 
Rxjs swetugg
Christoffer Noring
 
RxJava - introduction & design
allegro.tech
 
WebCamp:Front-end Developers Day. Александр Мостовенко "Rx.js - делаем асинхр...
GeeksLab Odessa
 
rx.js make async programming simpler
Alexander Mostovenko
 
Reactive programming and RxJS
Ravi Mone
 
DZone_RC_RxJS
Luis Atencio
 
Rxjs kyivjs 2015
Alexander Mostovenko
 
Introduction to RxJava on Android
Chris Arriola
 
Angular2 rxjs
Christoffer Noring
 
Ad

More from Tracy Lee (20)

PDF
Contributing to Open Source - Angular World Tour
Tracy Lee
 
PDF
ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...
Tracy Lee
 
PDF
Angular Girls Kansas City - The Power of Open Source and Social Media
Tracy Lee
 
PDF
Diversity & Inclusion Conference Talk - Refactr
Tracy Lee
 
PDF
Inclusive Architecture - Introducing the PAMstack - [Refactr.tech]
Tracy Lee
 
PDF
RxJS Operators - Real World Use Cases - AngularMix
Tracy Lee
 
PDF
Diversity, Inclusive Mindsets, and Architecture
Tracy Lee
 
PDF
Diversity & Inclusion Keynote at Open Source 101
Tracy Lee
 
PDF
Reactive programming with RxJS - ByteConf 2018
Tracy Lee
 
PDF
A Practical Approach to React Native at All Things Open Conference
Tracy Lee
 
PDF
React Native - Getting Started
Tracy Lee
 
PDF
An Introduction Into Using Angular’s Material Design
Tracy Lee
 
PDF
The Tale of the 3 CLIs - jDays2017
Tracy Lee
 
PDF
Angular Material (2) - NgVikingsConf
Tracy Lee
 
PDF
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Tracy Lee
 
PDF
A Tale of 3 CLIs - Angular 2, Ember, and React
Tracy Lee
 
PDF
Learning the New Tech Lingua Franca: Social Media
Tracy Lee
 
PDF
From 0 to Developer - Silicon Valley Code Camp
Tracy Lee
 
PDF
Creating BananaJS with Angular 2, Angular CLI, and Material Design
Tracy Lee
 
PDF
Ember.js - Harnessing Convention Over Configuration
Tracy Lee
 
Contributing to Open Source - Angular World Tour
Tracy Lee
 
ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...
Tracy Lee
 
Angular Girls Kansas City - The Power of Open Source and Social Media
Tracy Lee
 
Diversity & Inclusion Conference Talk - Refactr
Tracy Lee
 
Inclusive Architecture - Introducing the PAMstack - [Refactr.tech]
Tracy Lee
 
RxJS Operators - Real World Use Cases - AngularMix
Tracy Lee
 
Diversity, Inclusive Mindsets, and Architecture
Tracy Lee
 
Diversity & Inclusion Keynote at Open Source 101
Tracy Lee
 
Reactive programming with RxJS - ByteConf 2018
Tracy Lee
 
A Practical Approach to React Native at All Things Open Conference
Tracy Lee
 
React Native - Getting Started
Tracy Lee
 
An Introduction Into Using Angular’s Material Design
Tracy Lee
 
The Tale of the 3 CLIs - jDays2017
Tracy Lee
 
Angular Material (2) - NgVikingsConf
Tracy Lee
 
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Tracy Lee
 
A Tale of 3 CLIs - Angular 2, Ember, and React
Tracy Lee
 
Learning the New Tech Lingua Franca: Social Media
Tracy Lee
 
From 0 to Developer - Silicon Valley Code Camp
Tracy Lee
 
Creating BananaJS with Angular 2, Angular CLI, and Material Design
Tracy Lee
 
Ember.js - Harnessing Convention Over Configuration
Tracy Lee
 

Recently uploaded (20)

PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PDF
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
PDF
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
PPTX
Lifting and Rigging Safety AQG-2025-2.pptx
farrukhkhan658034
 
PPTX
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
PPTX
Machine Learning Benefits Across Industries
SynapseIndia
 
PDF
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
Upgrading to z_OS V2R4 Part 01 of 02.pdf
Flavio787771
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
PDF
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PDF
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
PDF
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
PDF
Productivity Management Software | Workstatus
Lovely Baghel
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
UiPath vs Other Automation Tools Meeting Presentation.pdf
Tracy Dixon
 
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
Fwdays
 
2025-07-15 EMEA Volledig Inzicht Dutch Webinar
ThousandEyes
 
Lifting and Rigging Safety AQG-2025-2.pptx
farrukhkhan658034
 
UI5Con 2025 - Beyond UI5 Controls with the Rise of Web Components
Wouter Lemaire
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Sustainable and comertially viable mining process.pdf
Avijit Kumar Roy
 
Machine Learning Benefits Across Industries
SynapseIndia
 
Market Wrap for 18th July 2025 by CIFDAQ
CIFDAQ
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Upgrading to z_OS V2R4 Part 01 of 02.pdf
Flavio787771
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
Bitcoin+ Escalando sin concesiones - Parte 1
Fernando Paredes García
 
Apache CloudStack 201: Let's Design & Build an IaaS Cloud
ShapeBlue
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Novus-Safe Pro: Brochure-What is Novus Safe Pro?.pdf
Novus Hi-Tech
 
Arcee AI - building and working with small language models (06/25)
Julien SIMON
 
Productivity Management Software | Workstatus
Lovely Baghel
 

RxJS - The Basics & The Future