-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
JavaScript Concurrency
By :
Before we dive right into the code examples, let's take a minute to make sure we have a firm grasp on the terminology surrounding promises. There are promise instances, but then there are also various states and actions to consider. The sections that follow will make much more sense if we can nail down the promise lexicon. These explanations are short and sweet, so if you've already used promises, you can quickly gloss over these definitions to sanity check your knowledge.
As the name suggests, a promise is, well, a promise. Think of a promise as a proxy for a value that doesn't exist yet. The promise let's us write better concurrent code because we know that the value will be there at some point, and we don't have to write lots of state-checking boilerplate code.
Promises are always in one of three states:
Pending: This is the first state of a promise after it's been created. It remains in a pending state until it's fulfilled or rejected.
Fulfilled: The promise...
Change the font size
Change margin width
Change background colour