Modern Asynchronous JavaScript
When it comes to writing asynchronous code in JavaScript, callbacks can be a hassle. In this course, you'll see alternatives to callbacks, including ES6 promises, and how to combine generators with promises to write async code in a synchronous style.
What you'll learn
In this course, Modern Asynchronous JavaScript, you will learn how to write asynchronous code that's a joy to maintain, not a burden. You will learn how to reason about promises, an alternative to callbacks, by creating a promise framework. Seeing promises from the perspective of a producer helps reason better about being the consumer of promise based APIs. Then, you will learn about ES6 generators and how to combine them with promises to write code that looks synchronous but that's actually asynchronous. This style cuts out the inherent verbosity of callbacks and even promises alone. When you're finished with this course, you'll know how to write asynchronous code in a fashion that's not a hassle to maintain.
Table of contents
- Callback Nesting Nightmare 6m
- What You Will Get out of This Course 2m
- What You Need to Know 7m
- How to Use This Course 1m
- Callbacks 5m
- Double-edged Sword: Explicit Async Seams 1m
- Con: Seams Rip Across Program 4m
- Con: Another Error Mechanism 3m
- Con: Hard to Reuse Error-handling Logic 1m
- Con: Difficult to Understand 3m
- Challenge: Synchronize Multiple Callbacks 5m
- Solution 6m
- Parallelism: Wouldn't This Be Nice? 3m
- One-shot Events 3m
- Takeaways 4m
- Why Build a Promise Framework? 2m
- Challenge - Split Success and Error Callbacks 2m
- Solution - Split Success and Error Callbacks 4m
- Add an Operations Suite 1m
- Using Done to Assert 3m
- Challenge - Pass the Callback Later 2m
- Solution - Pass the Callback Later 6m
- Question - Why Might This Separation Be Helpful? 1m
- Timing Safety without Coupling and Nesting 4m
- Challenge - Register Multiple Callbacks 5m
- Solution 3m
- Splitting Registration of Success and Error Callbacks 7m
- Convert getWeather to fetchWeather 3m
- Extracting the Operation Type 5m
- Operation Type Benefits 3m
- Get Me a Cup of Coffee 7m
- Challenge - Register a Callback Asynchronously 3m
- Solution - Register a Callback Asynchronously 4m
- Challenge - Parallelism 2m
- Solution - Parallelism 5m
- Challenge - Unnesting 1m
- Solution - Unnesting 4m
- Forwarding Completion 2m
- Waiting for the Completion of the Completion 2m
- Operation Does the Forwarding 6m
- Where Did the Nesting Go? 2m
- And Then 3m
- Chaining Recap 11m
- Shifting Perspective 2m
- Challenge - Error Recovery 2m
- Solution - Error Recovery 6m
- Async Error Recovery and Challenge - Forwarding Success 5m
- Forwarding Success and Challenge 3m
- Solution - Forwarding Errors 6m
- Reusing Error Handlers 2m
- Synchronous Result Transformation 6m
- Recover from Thrown Errors Too 4m
- Recover from Error Errors 1m
- Operations Should Only Complete One Time 3m
- Block Multiple Failures 1m
- Surrepticious Synchronicity 7m
- Ensuring Asynchronicity 3m
- Summary of Protections 4m
- Promises are Not New 5m
- Terminology 2m
- Why Is it Called Resolve? 7m
- Reworking Resolve 5m
- Challenge - Fixing Resolve 5m
- Defining Resolved 5m
- Executor - the Revealing Module Pattern 8m
- Deferred Versus Thenable 2m
- Executor with Callbacks 3m
- Static Resolve and Reject Functions 2m
- Testing with Promises and ES6 Promise Backward Compatibility 4m
- Why Third Party Promise Libraries Are Still Useful 3m
- Finally 1m
- Promisifying Existing Librarires You Love 4m
- Promise Collection Ops 2m
- Unhandled Rejection 7m
- Quizzary 9m
- Promises Aren't Perfect 4m
- Iterators 8m
- Generators 3m
- Generators Are Suspendable and Resumable Functions 6m
- When Resuming a Generator We Can Pass Errors 2m
- Calendars 4m
- Debugging Generators 5m
- I Would Like to Yield Promises 2m
- Yielding a Promise to My Assistant 4m
- Assisting with Infinite Promises 7m
- Four Async Ops in Four Lines of Code 2m
- Safety with Promise.resolve 2m
- Throwing Errors Back into the Generator 6m
- Catching Exceptions Throw from Generators 3m
- Catching Unhandled Errors in Our Assistant 4m
- Knowing When the Assistant Is Done 4m
- Wow 2m