Created
September 30, 2015 17:01
-
-
Save ryanwischkaemper/4ded1ddab26f15d616e5 to your computer and use it in GitHub Desktop.
Javascript synchronous promise execution
This file contains hidden or 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
var promises = []; | |
for(var i = 0; i < 10; i++)promises.push({config: i}); | |
// execute each request synchronously | |
return promises.reduce(function (promise, item) { | |
return promise.then(function () { | |
return myService.thatReturnsPromise(item); | |
}); | |
}, $q.when()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment