Promise.all and recursive functions
Hmm at first glance It's not really apparent why this isn't working. See next iteration to see the fix.
JavaScript
function recursiveFunction(n) {
console.log(n);
if (n === 0) {
return new Promise(function(resolve, reject) {
//resolve(n);
setTimeout(resolve, 100, n);
});
} else {
recursiveFunction(n-1);
}
}
function main() {
var p1 = new Promise(function(resolve, reject) {
setTimeout(resolve, 100, 'foo');
});
var p2 = recursiveFunction(3);
Promise.all([p1, p2]).then(function(values) {
console.log(values);
});
}
main();