Like I did in previous articles on the series, I would love to point out that you should probably set up Babel and follow along the examples with either a REPL or the
Thanks for reading that, and let’s go into Promises in ES6. Before reading this article you might want to read about arrow functions, as they’re heavily used throughout the article; and generators, as they’re somewhat related to the concepts discussed here.
I also wanted to mention Promisees – a promise visualization playground I made last week. It offers in-browser visualizations of how promises unfold. You can run those visualizations step by step, displaying how promises in any piece of code work. You can also record a gif of those visualizations, a few of which I’ll be displaying here in the article. Hope it helps!
If that animation looks insanely complicated to you, read on!
Promises are a very involved paradigm, so we’ll take it slow.
Here’s a table of contents with the topics we’ll cover in this article. Feel free to skip topics you’re comfortable about.
- What is a Promise? – we define
- Callbacks and Events – alternative ways to handle asynchronous code flows
- Gist of a
Promise– a first glimpse at how promises work
- Promises in Time – a brief history of promises
- Then, Again – an analysis of
- Creating a Promise From Scratch
- Settling a Promise – discusses states of a
- Paying a Promise with another Promise – explains promise chaining
- Transforming Values in Promises – shows how to turn a result into something else in the context of promises
Read more @ Pony Foo