About This Title

Pages: 75
Published: October 2021
ISBN: 9781680509045
Edition: 1
In Beta

Skill Level Meter

Modern Asynchronous JavaScript

Tackle Complex Async Tasks with Less Code

by Faraz K. Kelhini

JavaScript today must interact with data-intensive APIs and networks. The solution is a program that can work asynchronously instead of finishing tasks in order. In modern JavaScript, instead of callbacks you’ll use promises to improve your application’s performance and responsiveness. JavaScript features introduced in ES2020, ES2021, and ESNext like Promise.allSettled(),Promise.any(), and top-level await help you develop small, fast, low-profile applications. With the AbortController API, cancel a pending async request before it has completed. Modern Asynchronous JavaScript gives you an arsenal of tools to build programs that always respond to user requests, recover quickly from difficult conditions, and deliver maximum performance.

eBook Formats:

  • PDF for desktop/tablets

  • epub for Apple Books, e-readers

  • mobi for Kindle readers

Get all eBook formats here for $9.99 (USD)

Add to Cart we accept visa, mastercard, amex, discover, paypal

This book is in Beta, final version expected Oct 2021

Beta Books: What do I get?


Applications today must work with information on remote servers, and users expect a quick response to complex interactions at all times, whether on a high-speed 5G cellular network or slow public WiFi. JavaScript provides developers with advanced tools to coordinate the asynchronous parts of their code efficiently and deliver responsive programs. Faster applications equal happier users, which is the promise of asynchronous JavaScript.

With Modern Asynchronous JavaScript you’ll learn techniques for managing your async code. Features like ES2021 Promise.any() allow you to safeguard your async code from external issues that are out of your control like server downtime. You’ll discover secret weapons like top-level await to initialize resources, define dependency paths dynamically, and load dependencies with a fallback implementation. You’ll even learn to how to set a time limit for async requests and react if they take too long to complete.

Fast, reliable applications are a must in today’s world, where users demand increasingly greater amounts of data on mobile devices. Asynchronous programming may require more cautious planning than synchronous programming but the outcome is rewarding. Asynchronous JavaScript allows you to write code that is nimble but reliable, leading to programs that load faster, respond quicker, and most importantly that you can trust to function properly.

What You Need

You’ll need an intermediate level of JavaScript programming skills and a browser that supports features from ES2020, ES2021, and ESNext.

Resources

Releases:

  • B1.0 2021/09/09

Contents & Extracts

Note: Contents and extracts of beta books will change as the book is developed.

  • Preface
    • Who Is This Book For?
    • What You Should Know
    • What’s in This Book?
    • Online Resources
  • Introduction
    • Demystifying Asynchronous Execution
    • Working With Events
    • Working With Callback Functions
    • Introducing Promises
    • Creating Settled Promises
    • Handling Rejection
    • Managing Multiple Concurrent Promises
  • Creating Custom Asynchronous Iterators
    • Getting Ready
    • Creating a Custom Iterator
    • Creating a Custom Asynchronous Iterator
    • Iterating Over Async Iterables With for…await…of
    • Detecting Whether an Object Is Iterable
    • Wrapping Up
  • Enhancing Custom Iterators With Generators
  • Fetching Multiple Resources
  • Improving Reliability and Performance
    • Getting Ready
    • Using the Promise.any() Method
    • Avoiding the Single Point of Failure
    • Improving the Performance of Your App
    • Wrapping Up
  • Setting a Time Limit for Async Tasks
    • Getting Ready
    • Comparing Promise.race() to Promise.any()
    • Enforcing a Time Limit For Async Tasks
    • Wrapping Up
  • Canceling Pending Async Requests
    • Getting Ready
    • Canceling Async Tasks After a Period of Time
    • Handling an Aborted Request
    • Removing Multiple Event Listeners
    • Making a User Cancelable Async Request
    • Aborting Multiple Fetch Requests With One Signal
    • Wrapping Up
  • Accessing Promise Results From Another Module
    • Getting Ready
    • Using top-level await
    • Putting Top-Level Await to Work
    • Wrapping Up
    • Thank you for reading!

Author

Faraz Kelhini is a technical author at LogRocket who is passionate about moving the web forward and promoting patterns and ideas that make coding more productive. With more than a decade of software development experience, Faraz has in-depth knowledge of the JavaScript language and its related APIs. You can follow him on Twitter at @FarazKelhini.

eBook Formats:

  • PDF for desktop/tablets

  • epub for Apple Books, e-readers

  • mobi for Kindle readers

Get all eBook formats here for $9.99 (USD)

Add to Cart we accept visa, mastercard, amex, discover, paypal

This book is in Beta, final version expected Oct 2021

Beta Books: What do I get?

Related Titles:

Skill Level Meter

About This Title

Pages: 75
Published: October 2021
ISBN: 9781680509045
Edition: 1
In Beta