Closed ghost closed 9 years ago
@andrewschools from what you wrote, what you need is probably something as below:
var resultPromise = delay().then(function (delayResult) {
return delay2(delayResult);
})(function (delay2Result) {
return delay3(delay2Result);
});
resultPromise.done(function (delay3Result) {
// Process final result of delay3 function
});
Let me know if that answers your question
@medikoo - Thank you. This helped a lot. I guess I really didn't understand the concept of chaining. Much appreciated!
Hello -
I have an issue with using multiple promises that need to be resolved in order, as each one depends on the value from the previous resolved promise. I figured I could get away with initially initializing a promise to false and then set it to an actual promise via a function invocation but that doesn't seem to work. For example:
In the code above, the dPromise2 is null, however, the second thenable function is invoked immediately, printing "null" to the console. Same results if I initially set dPromsie2 to false.
I also tried initially setting dPromsie2 to deferred():
This immediately printed the following to the console:
If I change my 2nd thenable to what I have below it will hang.
I can actually get this all working if I move the 2nd thenable into the first one but I'm trying to avoid this. I also looked into chaining but that did not seem to work either.
As this will print:
Thank you!