Перейти к содержимому

How to Implement Promise.race with Conditional Short Circuit in Node.js & TypeScript

Rowadz

0:00 / 0:00

How to Implement Promise.race with Conditional Short Circuit in Node.js & TypeScript

285 просмотров · 3 года назад
Rowadz
22,7 тыс. подписчиков
285 просмотров · 3 года назад
In this video, you'll learn how to extend the power of Promise.race with conditional short-circuit logic in Node.js and TypeScript — a great pattern for improving async behavior under complex conditions. We cover how to: Track which promises finish first Use custom logic to decide when to "exit early" Avoid performance issues when racing multiple tasks ☕ Found this useful? Buy me a coffee: https://www.buymeacoffee.com/rowadz 📂 Code Example: https://gist.github.com/Rowadz/87cbb4... 📺 More on Promises: 🎊 Promises Techniques →    • Promises techniques 🎊   🪄 HTTP Orchestration →    • HTTP requests orchestration techniques 🪄   ⏱️ Timestamps: 00:00 Explaining the idea 02:25 Start writing the code 03:16 Creating a map to hold the promises' statuses 07:14 Calling Promise.race 07:58 Continuing the race 08:43 Testing 09:28 Testing with a delay 10:00 Testing with an error 11:02 Testing with a rejected promise