I think it's common to say that the Promise has resolved or settled. The resolution of the promise is the process in which the promise moves from the pending
state and acquires a value associated to said state. So, if a promise is either fulfilled
or rejected
it will be a resolved promise (as it's resolution process has ended). If a promise enters the resolution process and never transitions into any other state it is said that the promise is unresolved (the resolution process never ended).
Regarding the other terms rejected
or fulfilled
, they are the other two states in which a pending
promise can transition from. reject
is pretty obvious IMO, it handles cases in which failure is supposed to happen. Now I do agree that fulfill
can be somewhat ambiguous because it could simply mean that the promise has completed successfully (as in being resolved). It isn't supposed to describe the resolution process but the success (or the absence of error) of the task at hand.
The resolution process (to resolve a promise) can be observed in the A+ spec.
Edit.
The reason why people usually use resolve
as the first argument name it's because the callback passed as the first argument invokes the resolution process. It doesn't fulfill the promise (the promise can still be rejected), it just starts resolving the promise. The reject
mechanism isn't specified in the spec, it actually kind of short circuits the resolution process so that the promise is settled with reject
(not actually resolved you see).
Here are some examples where p
is rejected by using resolve
:
This is point 2.3.1.
var p = new Promise(resolve => setTimeout(() => resolve(p), 0));
This is point 2.3.2.3.
var p = Promise.resolve(Promise.reject('reason'));
This is point 2.3.3.2.
var thenable = { get then() { throw new Error(); } }
var p = Promise.resolve(thenable);
This is point 2.3.3.3.3
var thenable = {
then: function(resolvePromise, rejectPromise){
rejectPromise(new Error());
}
}
var p = Promise.resolve(thenable);
This is point 2.3.3.4.2
var thenable = {
then: function(){
throw new Error();
}
}
var p = Promise.resolve(thenable);
I used Promise.resolve
here instead of the first argument of the function passed down to the Promise constructor, but they should be the same. Many times the resolve
function passed down to the constructor is:
var p = this;
var cb = function(x){
resolve(p, x);
}
You can of course write down these tests as:
var p = new Promise(function(resolve){
resolve(thenable);
});