Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created November 14, 2015 19:01
Show Gist options
  • Save uhtred/3d3de7ab50069a124967 to your computer and use it in GitHub Desktop.
Save uhtred/3d3de7ab50069a124967 to your computer and use it in GitHub Desktop.
Serial Promises
function serial(tasks) {
var prevPromise;
angular.forEach(tasks, function(task) {
//First task
if (!prevPromise) {
prevPromise = task();
} else {
prevPromise = prevPromise.then(task);
}
});
return prevPromise;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment