Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:2Length:10 minutes

Next lesson playing in 5 seconds

Cancel

Free Preview: Asynchronous ES6 With Generators

Introduction

00:58
  • Overview
  • Transcript

Like promises, JavaScript generators are a way to improve asynchronous code readability by avoiding nested callbacks. Now that generators have come to JavaScript ES6 (ECMAScript) and are supported by Node as well as evergreen versions of Chrome, Edge, and Firefox, we can use them natively with no transpilation. Using promises is sure to improve the flow of your code.

In this Coffee Break Course, designed to teach a new skill or concept in a single sitting, Envato Tuts+ instructor Reggie Dawson will show you how to use generators for asynchronous JavaScript. You'll see how these powerful functions allow you to start and stop function execution at will.

Learn JavaScript: The Complete Guide

We've built a complete guide to help you learn JavaScript, whether you're just getting started as a web developer or you want to explore more advanced topics.

1.Asynchronous ES6 With Generators
2 lessons, 09:43

Free Lesson
1.1
Introduction
00:58

1.2
Asynchronous ES6 With Generators
08:45


1. Asynchronous ES6 With Generators

1.1 Introduction

[MUSIC] In this Coffee Break Course, we will learn how to create asynchronous behavior with ES6 generators. Generators are an alternative to call backs or promises and allow you to drop in and out of functions at will. This allows you to write code that allows you to wait for a remote server to upload data before rendering the contents of a web app for example. Truthfully, the uses I could find for generators is limitless. Before you can start to use them, you first need to understand how to use them. In this course, we will first learn the basics of the syntax and how to use generators. Then we will learn how we can communicate with our generators and pass data into them. Finally, we will learn how to use generators to account for the latency of grabbing data from remote sources. We will learn how to write asynchronous code that allows us to wait until our data is loaded before rendering the page. After viewing this course you should have a solid understanding of how generators work, and more importantly, how you can use them in your projects going forward.