You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var Q=require('q');
var staticWhen=Q.when(1);
var staticQ=Q(1);
function printStatusInfo(prom){
console.log(prom.isPending());
console.log(prom.isFulfilled());
console.log(prom.inspect());
}
printStatusInfo(staticWhen);
printStatusInfo(staticQ);
Only if you wait for the next tick you can have the static when promise fulfilled, while the static Q is fulfilled from the beginning.
I think this can be a problem if you substitute Q.when() for Q(), for example in a test that synchronously assert that the promise is fulfilled. Maybe it should be pointed in the docu that they behave differently in this case, because in the first paragraph of the reference says that they are equivalent.
The text was updated successfully, but these errors were encountered:
Hmm the docs first paragraph sais Q.when(X,Y) is equivalent to Q(X).then(Y). That is slighly different from saying Q.when(X) is equivalent to Q(X). It also states:
which will accept either a promise or a non-promise, and in the latter case create a fulfilled promise first
Maybe you can help me understand: If it is known that .then(Y) is fulfilled on the next tick then that means Q(X) has to be instantanious? So the behaviour can't change under those conditions? Because in my limited understanding making Q.(X) pending would make Q(X).then(Y) take two ticks... I'm not sure if that is accurate or if that is even breaking any expectations.
Have you checked whether Q(X).then() behaves equivalent to Q.when(X)?
I agree a clarification would be in order because neither the main readme nor the wiki docs are clear on the expected behaviour of when(X), only when(X,Y) is clearly defined right now.
I have a code similar to this in one of my tests.
and this outputs
Only if you wait for the next tick you can have the static when promise fulfilled, while the static Q is fulfilled from the beginning.
I think this can be a problem if you substitute Q.when() for Q(), for example in a test that synchronously assert that the promise is fulfilled. Maybe it should be pointed in the docu that they behave differently in this case, because in the first paragraph of the reference says that they are equivalent.
The text was updated successfully, but these errors were encountered: