(Related, but not quite the same: JS Promises: Fulfill vs Resolve )
I am trying to wrap my head around Javascript promises, and I am struggling with the basic concepts of permission and permission, against execution and execution. I read several submissions such as Jake Archibald , as well as browsing through some relevant specifications .
In States and Fates (not a completely official specification, but referred to as an authoritative document written by one of the authors of the performances), fulfilling this state when allowed is a "fate" (no matter what it is, but they are distinctly different):
Promises have three possible mutually exclusive conditions: completed, rejected, and expected.
- The promise is fulfilled if
promise.then(f)
calls f "as soon as possible."
and
A promise is allowed when trying to allow or reject , it has no effect, that is, the promise was “blocked” to either follow another promise or fulfilled or rejected
In particular, permitted covers both completed and rejected (and blocked). The "opposite" (or the directly corresponding function) for rejection is performed, not allowed; A solution includes rejection as one of its capabilities.
However, spec refers to the first argument to the then()
method (or its corresponding abstract concepts), using both execution and resolution:
25.4: The promise p is fulfilled if p.then ( f , r) immediately places the task to call the function f.
25.4.1.1: [[ Allow ]] Function Object The function that is used to resolve this promise object.
25.4.1.3. Set the internal slot [[Promise]] resolution . Set already [[AlreadyResolved]] internal slot to allow to already allowed. [Then immediately, failure is used in exactly the same way.]
25.4.5.3: Promise.prototype.then ( onFulfilled , onRejected)
Perhaps one of the most important is
25.4.4.5 Promise. allow (x)
which MDN describes as follows:
The Promise.resolve (value) method returns a Promise object that is allowed with the given value. If the value is obscured (that is, Has a "then" method), the returned promise "will follow" this, assuming its possible state; otherwise, the returned promise will be fulfilled with a value.
There is no mention of the Promise.resolve()
method, which may be rejected. In addition, there is a Promise.reject()
method, but not a Promise.fulfill()
method. So here, the opposite, to reject, is a decision, not an implementation.
Of course, there can be no guaranteed correlation between the permitted term "fate" and the decision of a method (or verb). But it would be (is it?) Really misleading and confusing so that resolve()
put the promise in a specially executed state when the terms fulfilled and resolved were carefully defined in order to have different meanings.
This is what happened here ... the right hand did not know what the left hand was doing, and we ended up with the documents, which should be the guiding lights of the movement, using the terms in inconsistent ways? Or is there something that I am missing, and resolving is actually a more suitable term than fulfilling the resolve()
method?
I am not going to criticize the authors of the document. I understand how difficult it is to get all the conditions that will be used consistently in all documents with a widely distributed history group. My goal here, delving into the terminology and wording of these documents, is to clearly understand the terms, which include knowing the limits of how accurately terms can be defined, such as implementation and resolution. Jake Archibald admits that he sometimes mixes the terms. This is a very useful confession for noobs like me who are trying to understand terminology! Thank you, Jake, for being vulnerable. :-) My goal in asking this question is to find out which definitions or applications of these terms are reliable? Or should I conclude that a solution is sometimes used specifically to mean fulfillment, and sometimes execute / reject / block even in the most authoritative documents?