Open ForbesLindesay opened 11 years ago
Very interesting, thanks for bringing this up! My first instinct is that synchronicity would be bizarre. But, not based on anything concerete yet.
Let's try this similar scenario:
let {promise, resolve} = defer();
console.log(1);
resolve(null);
promise.then(() => console.log(4));
console.log(2);
console.log(3);
The only thing this can be, by Promises/A+, is
1
2
3
4
To me it seems weird that the output would change depending on whether you hooked up the then
before or after the resolve
.
Another question is how that plays with 'synchronous inspection'.
We've had the discussion and accepted that Promises/A+ promises are always asynchronous for
then
but what about for calls toresolve
If resolve is allowed to be synchronous, this could result in:
But if it must be asynchronous then it must result in
Because of the restrictions of Promises/A+ it can never result in
So what's it to be? Do we force asynchronous behavior?