Preface

The asynchronous nature of JavaScript is one of the aspects of the language that can confuse a lot of people. Having a good understanding of its primary async constructs however can reduce a lot of confusion about the language. The goal of this book is to introduce you to async programming in JavaScript and provide you with the necessary techniques to write clean and maintainable async code. We will start by exploring synchronous and asynchronous execution models and their differences. Then we'll dive into callback functions and examine how they are used to capture results of async operations. After that, we'll explore promises and learn how they abstract callback functions to simplify async flows. And at the end we'll explore async functions and illustrate how they can be used along with promises to further simplify asynchronous operations.

Book Outline

Chapter 1: Introduction focuses on the async model in JavaScript. It explores the key differences between async and synchronous models

Chapter 2: Callbacks describes what callbacks are and how they are used to capture results of async operations

Chapter 3: Promises introduces promises and how they can be used to manage async operations

Chapter 4: Generators goes over generator functions and explains how they can be used for different purposes including async tasks

Chapter 5: Async Await explores the asycn/await abstraction around generators and promises and how they can be used to simplify async flows

Using the Project Files

All the source code and project files are available on Github: https://github.com/aminmeyghani/asyncjs-book. You can simply clone the repository and run the code snippets included in the code directory. Alternatively you can download the repository as a zip file. If you have any feedback or find any issues with the book you can create an issue on the Github repository. Just make sure to use an appropriate tag for the issue that you create.

Requirements

This book assumes that you know the basics of JavaScript and Node. All the code snippets assumes a unix-like environment. If you are on Windows you may wanna try something like Cygwin to get a unix-like environment.

Code Blocks

Code examples will be shown in code blocks. You can see some examples below:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <p>Some html</p>
</body>
</html>
.hello {
  color: #fff;
}
function x() {
  return 5;
}

Book Updates

This book will be periodically updated with new chapters and exercises. Make sure to join the slack channel at https://asyncjsbook.now.sh to get updates and discuss what you want to see next in the book.

results matching ""

    No results matching ""