-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
JavaScript Concurrency
By :
Each promise method that we examined so far in this chapter returns promises. This allows us to call these methods again on the return value, resulting in a chain of then().then() calls, and so forth. One challenging aspect of chaining promise calls together is that the instances returned by promise methods are new instances. That is, there's a degree of immutability to the promises that we'll explore in this section.
As our application gets larger, the concurrency challenges grow with it. This means that we need to think of better ways to leverage synchronization primitives, such as promises. Just as any other primitive value in JavaScript, we can pass them around from function to function. We have to treat promises in the same way—passing them around, and building upon the chain of callback functions.
Promises are born into a pending state, and they die in either a resolved or rejected state. Once a promise has transitioned...
Change the font size
Change margin width
Change background colour