Rules For Promises
A standard for promises was defined by the Promises/A+ specification community, highly recommend this resource if you want to learn more about promises and even implementing it in other languages like python, ActionScript, and Java.
- A promise or “thenable” is an object that supplies a standard-compliant
- A pending promise may transition into a fulfilled or rejected state.
- A fulfilled or rejected promise is settled, and must not transition into any other state.
- Once a promise is settled, it must have a value (which may be
undefined). That value must not change.
In ES6 promise constructors take in a function. The function can be one of 2 things, resolve(which gives us a value) and rejected(which gives us an error).
The “.catch()” in the end is used for when the promise is rejected and we receive an error message. Both the .then() and the .catch() methods will avoid the other if resolved or rejected is true. Meaning resolved promises will miss the .catch() and rejected promises will miss any of the .then().
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting…
There are many conformant implementations of Promises/A+. Here are the ones we know about. Note that an…