-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about thenable values #193
Comments
👍 |
👍 Chrome is wrong here. Two callbacks on the same A more interesting example would be var promise = Promise.resolve({});
promise.then(function (value) {
value.then = function (onFulfilled) {
onFulfilled(125);
};
return promise;
}).then(function (value) {
console.log(value); // what do they do here?
});
|
It sure seems that way to me too. IMHO, you shouldn't be able to trick the machinery by turning a promise's fulfillment value into a thenable after fact. FWIW, when.js, bluebird, and rsvp all seem to log an object.
Node 0.12.2 and io.js 2.0.1 native Promise also log |
(deleted previous comments as I didn't read prior code quite carefully enough) @Octane's example should definitely always log the object, because the resolution algorithm is applied at the time the promise is created, not when var promise = Promise.resolve({});
promise.then(function (value) {
value.then = function (onFulfilled) {
onFulfilled(125);
};
return promise;
}).then(function (value) {
console.log(value); // what do they do here?
}); Is a more interesting example. If we follow the Promises/A+ spec, The ES6 spec is a little more difficult to dissect, but I think it suggests that it should log 125 in this instance because https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-resolve-functions doesn't appear to differentiate between thenables and true promises. |
I came across the following problem:
This example works differently in Chrome 44 and Firefox 40. Who is wrong?
http://jsbin.com/losuze/1/edit?js,console
The text was updated successfully, but these errors were encountered: