SlideShare a Scribd company logo
1 of 61
Download to read offline
RxJS
A Beginner & Expert’s Perspective
@benlesh | @ladyleet
@benlesh | @ladyleet
Learning RxJS Be Like...
Couldn’t find the right docs!
@benlesh | @ladyleet
What do these operators even do?
Learning RxJS Be Like...
@benlesh | @ladyleet
How do I wrap APIs in Observables?
Learning RxJS Be Like...
@benlesh | @ladyleet
Oops, I forgot to subscribe. (╯°□°)╯︵ ┻━┻
Learning RxJS Be Like...
@benlesh | @ladyleet
@benlesh | @ladyleet
Tracy Lee
@ladyleet
A Beginner & Expert’s Perspective
Ben Lesh
@benlesh
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Google
Developer
Expert
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Google
Developer
Expert
Co-Founder
This Dot Labs
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Google
Developer
Expert
Co-Founder
This Dot Labs
Learned RxJS
a few months
ago
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Software
Engineer,
Google
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Software
Engineer,
Google
Formerly
Netflix
Tracy Lee
@ladyleet
Beginner & Expert
Ben Lesh
@benlesh
Software
Engineer,
Google
Formerly
Netflix
RxJS5+
Lead
@benlesh | @ladyleet
A Beginner & Expert’s Perspective
On Learning & Using RxJS
- How to create an Observable
- 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”
@benlesh | @ladyleet
const x = new Observable(observer => {
observer.next(‘hi’);
observer.complete();
});
@benlesh | @ladyleet
Creating a New Observable
Many other Observable
creation methods
@benlesh | @ladyleet
@benlesh | @ladyleet
Versions
Angular 4.0.1
Angular-CLI 1.0.0
RxJS 5.3.0
Angular Material 2.0.0-beta.2
@benlesh | @ladyleet
// Add a funny pun about Angular 4 and
Angular CLI
@benlesh | @ladyleet
Lookahead Search
The Idiomatic RxJS Example
@benlesh | @ladyleet
Add an <input> to your component’s template
@benlesh | @ladyleet
Getting Observable of text changes from input
Use Subject as an event handler in input event
@benlesh | @ladyleet
Getting Observable of text changes from input
Use a template reference variable to get the text value
@benlesh | @ladyleet
Getting Observable of text changes from input
Using the next method to push values through the Observable
@benlesh | @ladyleet
Getting Observable of text changes from input
Import Subject from RxJS
@benlesh | @ladyleet
Getting Observable of text changes from input
Add the Subject
@benlesh | @ladyleet
Getting Observable of text changes from your input
On the subject of Subjects...
- 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
@benlesh | @ladyleet
@benlesh | @ladyleet
Importing RxJS
… this is where a lot of beginners make a mistake
Beginner Mistake: Importing ALL of RxJS 5
@benlesh | @ladyleet
Include Just What You Need
@benlesh | @ladyleet
Back to Our Pun App
We have an Observable of text input changes - keywordInputChange$
… give us the keywords we might be looking for!
@benlesh | @ladyleet
To Get Our Data, We’ve Created “PunService”
@benlesh | @ladyleet
PunService Uses Http From @angular/http
@benlesh | @ladyleet
Take Observable of Textbox Changes and
Get a List of Suggested Keywords
@benlesh | @ladyleet
switchMap
Converts the value to a new observable, then switches to that observable
(unsubscribing from any previous ones it might have made)
@benlesh | @ladyleet
@benlesh | @ladyleet
Operators: Why switchMap?
@benlesh | @ladyleet
Writing Suggested Keywords to the View
Get List of Puns from List of Keywords
@benlesh | @ladyleet
Displaying Puns
@benlesh | @ladyleet
Subscribing to keyword$
@benlesh | @ladyleet
Let’s Share keyword$
@benlesh | @ladyleet
@benlesh | @ladyleet
Same Shaped-ness
Let’s add another data source!
@benlesh | @ladyleet
Web Speech API
https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API
@benlesh | @ladyleet
Wrap an API in an Observable
@benlesh | @ladyleet
Wrap an API in an Observable
@benlesh | @ladyleet
Wrap an API in an Observable
@benlesh | @ladyleet
An Angular Service
- Injectable
- Actually use all results
- Add error handling
@benlesh | @ladyleet
Add Button to Trigger Speech Recognition
@benlesh | @ladyleet
Pump our clicks through a Subject
@benlesh | @ladyleet
Inject SpeechService
@benlesh | @ladyleet
switchMap Clicks into Speech Recognition
@benlesh | @ladyleet
Merge Typed Keyword Suggestions With Spoken Ones
@benlesh | @ladyleet
Same shaped-ness!
This works because they’re both Observable<string[]>
@benlesh | @ladyleet
@benlesh | @ladyleet
A Beginner & Expert’s Perspective
On Learning & Using RxJS
- How to create an Observable
- 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”
@benlesh | @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/
@benlesh | @ladyleet
Thank You!
@benlesh | @ladyleet

More Related Content

What's hot

Creating a server side web app
Creating a server side web appCreating a server side web app
Creating a server side web app
jeremyk23
 

What's hot (20)

React For Vikings
React For VikingsReact For Vikings
React For Vikings
 
The dev ops code has no servers
The dev ops code has no serversThe dev ops code has no servers
The dev ops code has no servers
 
New Theme Directory
New Theme DirectoryNew Theme Directory
New Theme Directory
 
The Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cliThe Tale of 2 CLIs - Ember-cli and Angular-cli
The Tale of 2 CLIs - Ember-cli and Angular-cli
 
Wrapping and Securing REST APIs with GraphQL
Wrapping and Securing REST APIs with GraphQLWrapping and Securing REST APIs with GraphQL
Wrapping and Securing REST APIs with GraphQL
 
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
 
Creating a server side web app
Creating a server side web appCreating a server side web app
Creating a server side web app
 
Getting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLIGetting Started with the Angular 2 CLI
Getting Started with the Angular 2 CLI
 
Discover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset APIDiscover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset API
 
Why you should add React to your Rails application now!
Why you should add React to your Rails application now!Why you should add React to your Rails application now!
Why you should add React to your Rails application now!
 
A Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js GlueA Debugging Adventure: Journey through Ember.js Glue
A Debugging Adventure: Journey through Ember.js Glue
 
Wrapping and securing REST APIs with GraphQL
Wrapping and securing REST APIs with GraphQLWrapping and securing REST APIs with GraphQL
Wrapping and securing REST APIs with GraphQL
 
Writing Alexa Voice Skills With NodeJS (with a little IoT)
Writing Alexa Voice Skills With NodeJS (with a little IoT)Writing Alexa Voice Skills With NodeJS (with a little IoT)
Writing Alexa Voice Skills With NodeJS (with a little IoT)
 
State management with GraphQL [Angular Minsk, Online, 13.06.20]
State management with GraphQL [Angular Minsk, Online, 13.06.20]State management with GraphQL [Angular Minsk, Online, 13.06.20]
State management with GraphQL [Angular Minsk, Online, 13.06.20]
 
Declaring Server App Components in Pure Java
Declaring Server App Components in Pure JavaDeclaring Server App Components in Pure Java
Declaring Server App Components in Pure Java
 
Getting started with Angular CLI
Getting started with Angular CLIGetting started with Angular CLI
Getting started with Angular CLI
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
AngularJS RTP Slides - Angular 2 Demo #ngtattoo with Angular CLI, Newest New ...
 
MeteorJS Session
MeteorJS SessionMeteorJS Session
MeteorJS Session
 
Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?
 

Viewers also liked

Viewers also liked (6)

'The History of Metrics According to me' by Stephen Day
'The History of Metrics According to me' by Stephen Day'The History of Metrics According to me' by Stephen Day
'The History of Metrics According to me' by Stephen Day
 
RxJS Evolved
RxJS EvolvedRxJS Evolved
RxJS Evolved
 
RxJs
RxJsRxJs
RxJs
 
You will learn RxJS in 2017
You will learn RxJS in 2017You will learn RxJS in 2017
You will learn RxJS in 2017
 
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
 

Similar to RxJS: A Beginner & Expert's Perspective - ng-conf 2017

Similar to RxJS: A Beginner & Expert's Perspective - ng-conf 2017 (20)

The Functional Programming Toolkit (NDC Oslo 2019)
The Functional Programming Toolkit (NDC Oslo 2019)The Functional Programming Toolkit (NDC Oslo 2019)
The Functional Programming Toolkit (NDC Oslo 2019)
 
Ruby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich CollinsRuby on Rails Plugins - Rich Collins
Ruby on Rails Plugins - Rich Collins
 
THE SCIENCE AND ART OF BACKWARDS COMPATIBILITY
THE SCIENCE AND ART OF BACKWARDS COMPATIBILITYTHE SCIENCE AND ART OF BACKWARDS COMPATIBILITY
THE SCIENCE AND ART OF BACKWARDS COMPATIBILITY
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
StudentQuerySystemPPT.pptx
StudentQuerySystemPPT.pptxStudentQuerySystemPPT.pptx
StudentQuerySystemPPT.pptx
 
Lecture: Refactoring
Lecture: RefactoringLecture: Refactoring
Lecture: Refactoring
 
Will be an introduction to
Will be an introduction toWill be an introduction to
Will be an introduction to
 
APIdays Paris 2019 Backend is the new frontend by Antoine Cheron
APIdays Paris 2019 Backend is the new frontend by Antoine CheronAPIdays Paris 2019 Backend is the new frontend by Antoine Cheron
APIdays Paris 2019 Backend is the new frontend by Antoine Cheron
 
The complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrrThe complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrr
 
php app development 1
php app development 1php app development 1
php app development 1
 
Ember.js - Harnessing Convention Over Configuration
Ember.js - Harnessing Convention Over ConfigurationEmber.js - Harnessing Convention Over Configuration
Ember.js - Harnessing Convention Over Configuration
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting Started
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Rails OO views
Rails OO viewsRails OO views
Rails OO views
 
Integrations with the Force.com Platform Using Custom Apex REST Services
Integrations with the Force.com Platform Using Custom Apex REST ServicesIntegrations with the Force.com Platform Using Custom Apex REST Services
Integrations with the Force.com Platform Using Custom Apex REST Services
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
You Can Do It in SQL
You Can Do It in SQLYou Can Do It in SQL
You Can Do It in SQL
 
PHP Basics
PHP BasicsPHP Basics
PHP Basics
 
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"
 

More from Tracy Lee

More from Tracy Lee (16)

Contributing to Open Source - Angular World Tour
Contributing to Open Source - Angular World TourContributing to Open Source - Angular World Tour
Contributing to Open Source - Angular World Tour
 
ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...
ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...
ChicagoJS's JSCAMP 2019 Keynote - Inclusive Architecture - Building Sustainab...
 
Angular Girls Kansas City - The Power of Open Source and Social Media
Angular Girls Kansas City - The Power of Open Source and Social MediaAngular Girls Kansas City - The Power of Open Source and Social Media
Angular Girls Kansas City - The Power of Open Source and Social Media
 
Diversity & Inclusion Conference Talk - Refactr
Diversity & Inclusion Conference Talk - RefactrDiversity & Inclusion Conference Talk - Refactr
Diversity & Inclusion Conference Talk - Refactr
 
Inclusive Architecture - Introducing the PAMstack - [Refactr.tech]
Inclusive Architecture - Introducing the PAMstack - [Refactr.tech] Inclusive Architecture - Introducing the PAMstack - [Refactr.tech]
Inclusive Architecture - Introducing the PAMstack - [Refactr.tech]
 
RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)RxJS Operators - Real World Use Cases (FULL VERSION)
RxJS Operators - Real World Use Cases (FULL VERSION)
 
RxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMixRxJS Operators - Real World Use Cases - AngularMix
RxJS Operators - Real World Use Cases - AngularMix
 
Diversity, Inclusive Mindsets, and Architecture
Diversity, Inclusive Mindsets, and ArchitectureDiversity, Inclusive Mindsets, and Architecture
Diversity, Inclusive Mindsets, and Architecture
 
Diversity & Inclusion Keynote at Open Source 101
Diversity & Inclusion Keynote at Open Source 101Diversity & Inclusion Keynote at Open Source 101
Diversity & Inclusion Keynote at Open Source 101
 
Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018
 
An Introduction Into Using Angular’s Material Design
An Introduction Into Using Angular’s Material DesignAn Introduction Into Using Angular’s Material Design
An Introduction Into Using Angular’s Material Design
 
The Tale of the 3 CLIs - jDays2017
The Tale of the 3 CLIs - jDays2017The Tale of the 3 CLIs - jDays2017
The Tale of the 3 CLIs - jDays2017
 
Angular Material (2) - NgVikingsConf
Angular Material (2) - NgVikingsConfAngular Material (2) - NgVikingsConf
Angular Material (2) - NgVikingsConf
 
Learning the New Tech Lingua Franca: Social Media
Learning the New Tech Lingua Franca: Social MediaLearning the New Tech Lingua Franca: Social Media
Learning the New Tech Lingua Franca: Social Media
 
From 0 to Developer - Silicon Valley Code Camp
From 0 to Developer - Silicon Valley Code CampFrom 0 to Developer - Silicon Valley Code Camp
From 0 to Developer - Silicon Valley Code Camp
 
From 0 to Ember
From 0 to EmberFrom 0 to Ember
From 0 to Ember
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

RxJS: A Beginner & Expert's Perspective - ng-conf 2017