-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
In Q, if an async generator returns a promise, that promise is resolved and the resolved value is passed on. In Bluebird, the promise itself is passed along as the next value:
Q v1.0.0:
Q.async(function* () {
return Promise.resolve("")
})()
.then(function (str) {
alert(typeof str); // 'string'
})
.done();
Bluebird v0.11.6-1:
Promise.spawn(function* () {
return Promise.resolve("");
})
.then(function (str) {
alert(typeof str); // 'object'
});
The workaround in Bluebird is to yield on the promise before returning it:
Promise.spawn(function* () {
return yield Promise.resolve("");
})
.then(function (str) {
alert(typeof str); // 'string'
});
But that seems like an unnecessary extra step that could be avoided, and I think it goes against expectations coming from Promise.try(). Is this behavior intentional?