Created
December 15, 2017 03:25
-
-
Save danielsotopino/20cb062d0a59ee583ffcb24e2bdbed5d to your computer and use it in GitHub Desktop.
Synchronous recursive promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.recurse = function(promises, promisesLength, results) { | |
if (promisesLength === 1) { | |
return promises[0].then(function(data){ | |
results.push(data); | |
return results; | |
}); | |
} | |
return promises[promisesLength-1].then(function(data) { | |
results.push(data); | |
return $scope.recurse(promises, promisesLength - 1, results); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment