Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
You don't know Promises - IT Konekt April 2019
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ivan Jovanovic
April 20, 2019
Technology
65
1
Share
You don't know Promises - IT Konekt April 2019
Ivan Jovanovic
April 20, 2019
More Decks by Ivan Jovanovic
See All by Ivan Jovanovic
Micro Frontends - A microservice approach to the modern web - Oredev 2019
ivanjov
0
92
Micro Frontends - A microservice approach to the modern web - O'Reilly Software Architecture Berlin 2019
ivanjov
0
77
React State - The Good, the Bad and the Ugly - ArmadaJS
ivanjov
0
120
Thinking Reactive in JavaScript - Sphere.it JS Krakow
ivanjov
0
74
Micro Frontends - A microservice approach to the modern web - PHPSrbija
ivanjov
0
220
Micro Frontends - A microservice approach to the modern web - Codemotion Rome 2019
ivanjov
0
340
Mikro Frontendi - Uvod - Novi Sad JS
ivanjov
0
170
Software engineer marketing done right – career tips from my experience.
ivanjov
0
45
Micro Frontends - A microservice approach to the modern web - Full Stack London 2018
ivanjov
0
240
Other Decks in Technology
See All in Technology
要件定義の精度を高めるための型と生成AIの活用 / Using Types and Generative AI to Improve the Accuracy of Requirements Definition
haru860
0
310
Agent の「自由」と「安全」〜未来に向けて今できること〜
katayan
0
340
「QA=テスト」「シフトレフト=スクラムイベントの参加者の一員」の呪縛を解く。アジャイルな開発を止めないために、10Xで挑んだ「右側のしわ寄せ」解消記 #scrumniigata
nihonbuson
PRO
3
930
生成AIはソフトウェア開発の革命か、ソフトウェア工学の宿題再提出なのか -ソフトウェア品質特性の追加提案-
kyonmm
PRO
2
860
Percolatorを廃止し、マルチ検索サービスへ刷新した話 / Search Engineering Tech Talk 2026 Spring
visional_engineering_and_design
0
330
巨大プラットフォームを進化させる「第3のROI」
recruitengineers
PRO
2
2.5k
AI時代に越境し、 組織を変えるQAスキルの正体 / QA Skills for Transforming an Organization
mii3king
5
4.1k
データモデリング通り #5オンライン勉強会: AIに『ビジネスの文脈』を教え込むデータモデリング
datayokocho
0
190
アクセシビリティはすべての人のもの
tomokusaba
0
290
アプリブロック機能のつくりかたと、AIとHTMLの不合理な相性の良さについて
kumamotone
0
140
Building a Study Buddy AI Agent from Scratch: From Passive Chatbots to Autonomous Systems
itchimonji
0
140
【技術書典20】OpenFOAM(自宅で深める流体解析)流れと熱移動(2)
kamakiri1225
0
380
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Odyssey Design
rkendrick25
PRO
2
610
エンジニアに許された特別な時間の終わり
watany
106
240k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
4 Signs Your Business is Dying
shpigford
187
22k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Evolving SEO for Evolving Search Engines
ryanjones
0
190
The World Runs on Bad Software
bkeepers
PRO
72
12k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
510
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
350
Transcript
You don't know Promises
I am Ivan Jovanovic Senior Software Engineer, Tech Speaker You
can find me at @ivanjov96 or https://ivanjov.com Hello! IJ Consulting
Why I don't know Promises?
None
None
I am here today To show you how Promises really
work!
JavaScript is strange because ‒ It was built for 10
days ‒ It has one thread ‒ It is synchronous and asynchronous ‒ It is everywhere ‒ It is different
Only one thread And the event loop
None
How do we handle async code? Promises Callbacks Async/await
Callbacks Where everything began... 1
“ A callback is a function that is passed as
an argument and will be executed after another function has finished executing.
None
None
Promises Changed everything 2
“ The Promise object represents the eventual completion (or failure)
of an asynchronous operation, and its resulting value.
None
None
How Promises really work? The answer is a Microtask queue!
None
Microtask queue ‒ Independent queue ‒ Used by: process.nextTick, Promises,
Object.observe, MutationObserver ‒ Faster than the main queue and may be drained several times in a single event loop tick
None
Next TICK ONE Next TICK TWO TIMEOUT AFTER-ONE TIMEOUT AFTER-TWO
Promise methods ‒ Promise.all(iterable) ‒ Promise.race(iterable) ‒ Promise.resolve(value) ‒ Promise.reject(reason)
Promise.all(iterable)
Rejected situation
Promise.race(iterable)
Promisify non-Promise code
Native Promises from libraries
Async/await Comes to the rescue 3
“ Async/Await is a special syntax for working with Promises.
None
Most common problems with Promises that we see every day!
9
Nested promises 1
None
None
Broken Promise chain 2
None
None
Mixing sync and async code 3
None
None
None
Missing catch 4
None
None
None
Forget to return a Promise 5
None
None
Promisified synchronous code 6
None
Mixing Promise and Async/Await 7
None
None
Async function that returns Promise 8
None
None
None
Define a callback as an async function 9
None
Clinic.js https://clinicjs.org/
Conclusion ‒ JS is crazy and great at the same
time! ‒ Async behavior is a pro, not a con. ‒ Be careful when using Promises, it's great and dangerous at the same time!
Any questions ? You can find me at ‒ @ivanjov96
‒
[email protected]
Thanks!