SlideShare a Scribd company logo
The Async JS Saga
Harshit Juneja
@sayhitoharshit
Async Patterns
● Callbacks
● Promises
● Generators and Iterators
● Generators and Iterators + promises
● Async-await
● Web workers
● Observables
What’s JS ?
● Single Threaded
● Non Blocking
● Asynchronous
● Concurrent
Callbacks
Callbacks
Then I got to know about this!
Problems with Callbacks
● Difficult to understand and plan for our sequential brain
● Implicitly hands over control to another party
● Trust Issues
● Callback Hell
The Async JS Saga
Misconception about Callback Hell!
Enter Promises
Just Socially Acceptable Callbacks
The Async JS Saga
Enter Generators and Iterators
● Python inspired concept
● Breaks Run-to-completion
● Easy on human brain
The Async JS Saga
The Async JS Saga
The Async JS Saga
You still have callbacks!
The Async JS Saga
Async-Await (The best of both worlds)
Web workers
● Use the Web Workers API
● Run your JS in background threads
● Non blocking : without interfering with the UI
● Useful for any large computations.
● Can send messages to JS code by posting messages to an event handler
The Async JS Saga
Observables
● Suited for event streams
● Avoids memory leaks
● Implemented through external libraries (RxJS being the most used)
● Still to make it to the spec

More Related Content

PDF
All Aboard The Stateful Train
PDF
Magento 2 - Replacing God with Dependency Injection
PDF
React Native: How It Works
ODP
Focus on the outside, testing in ASP.NET MVC
KEY
My Top 10 Secret Weapons for Frontend Development
PPTX
Async ... Await – concurrency in java script
PPTX
Async patterns in javascript
PDF
Node in Real Time - The Beginning
All Aboard The Stateful Train
Magento 2 - Replacing God with Dependency Injection
React Native: How It Works
Focus on the outside, testing in ASP.NET MVC
My Top 10 Secret Weapons for Frontend Development
Async ... Await – concurrency in java script
Async patterns in javascript
Node in Real Time - The Beginning

Similar to The Async JS Saga (20)

PDF
Developing Async Sense
PDF
Asynchronous development in JavaScript
PPTX
NodeJS Concurrency
PDF
The art of concurrent programming
PDF
The Strange World of Javascript and all its little Asynchronous Beasts
PDF
Steam Learn: Asynchronous Javascript
PDF
The evolution of asynchronous javascript
PPTX
PPTX
Async discussion 9_29_15
PPTX
JS Event Loop
PDF
Intro to Asynchronous Javascript
PDF
FITC - Node.js 101
PDF
JavaScript, un langage plein de promesses
PDF
Introduction to Node JS2.pdf
PPTX
How NOT to write in Node.js
PPT
18_Node.js.ppt
PPT
18_Node.js.ppt
PDF
Node.js Patterns and Opinions
PDF
Frontend Track NodeJS
PDF
Promises generatorscallbacks
Developing Async Sense
Asynchronous development in JavaScript
NodeJS Concurrency
The art of concurrent programming
The Strange World of Javascript and all its little Asynchronous Beasts
Steam Learn: Asynchronous Javascript
The evolution of asynchronous javascript
Async discussion 9_29_15
JS Event Loop
Intro to Asynchronous Javascript
FITC - Node.js 101
JavaScript, un langage plein de promesses
Introduction to Node JS2.pdf
How NOT to write in Node.js
18_Node.js.ppt
18_Node.js.ppt
Node.js Patterns and Opinions
Frontend Track NodeJS
Promises generatorscallbacks
Ad

Recently uploaded (20)

PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Ship’s Structural Components.pptx 7.7 Mb
PPTX
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PDF
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
PDF
Introduction to Data Science: data science process
PPTX
Internship_Presentation_Final engineering.pptx
PDF
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PDF
flutter Launcher Icons, Splash Screens & Fonts
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
PPT
Drone Technology Electronics components_1
PPT
Chapter 6 Design in software Engineeing.ppt
PDF
ETO & MEO Certificate of Competency Questions and Answers
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPT
SCOPE_~1- technology of green house and poyhouse
PDF
Queuing formulas to evaluate throughputs and servers
PPTX
TE-AI-Unit VI notes using planning model
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Lesson 3_Tessellation.pptx finite Mathematics
Ship’s Structural Components.pptx 7.7 Mb
MET 305 MODULE 1 KTU 2019 SCHEME 25.pptx
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
algorithms-16-00088-v2hghjjnjnhhhnnjhj.pdf
Introduction to Data Science: data science process
Internship_Presentation_Final engineering.pptx
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
flutter Launcher Icons, Splash Screens & Fonts
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
Drone Technology Electronics components_1
Chapter 6 Design in software Engineeing.ppt
ETO & MEO Certificate of Competency Questions and Answers
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
SCOPE_~1- technology of green house and poyhouse
Queuing formulas to evaluate throughputs and servers
TE-AI-Unit VI notes using planning model
Ad

The Async JS Saga

Editor's Notes

  • #4: When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes.