liveBook · Manning

Fulfilled state

As explained in Secrets of the JavaScript Ninja, Third Edition

The fulfilled state is a promise state indicating that the asynchronous operation completed successfully with a value.

A promise is fulfilled when its asynchronous operation completes successfully. It carries an associated value, and fulfillment is one of the two settled states; the other is rejection. section 8.1.1

Keep these state rules in mind:

  • A promise starts pending, and its state and value become permanent once it is settled. section 8.1.1
  • Calling resolve with an ordinary value fulfills the promise with that value; resolving with another promise adopts that promise’s outcome, which may be rejection instead. section 8.1.1
  • A fulfilled promise can pass its value to a then callback; the callback’s return value determines the next promise’s resolution. section 8.1.2
Figure 8.1 The possible states of a promise: pending, fulfilled, rejected. The value associated with the rejected state is often called a reason.

Use the state diagram to compare fulfillment with pending and rejection, and see that settled states carry values. section 8.1.1

Adopting another promise’s outcome

Resolving one promise with a fulfilled promise leads to fulfillment; resolving another with a rejected promise leads to rejection. Calling resolve does not guarantee that the resulting promise is fulfilled. section 8.1.1

How Secrets of the JavaScript Ninja, Third Edition covers it

How deep it goes
Defines fulfillment, settlement, and state permanence, then explains ordinary values and adoption during resolution.
Examples
Uses a timer resolving with undefined and promises resolved with fulfilled or rejected promises.
What you can do after
Evaluate how promises signal successful completion and pass values into subsequent then callbacks.
How it connects
Connects fulfillment to promises, settlement, rejection, resolve, and then callbacks.

Also explained in

Compare how 3 books explain fulfilled state →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Third Edition. The section links point to the parts of the book it draws on.