Created
November 14, 2015 19:01
-
-
Save uhtred/3d3de7ab50069a124967 to your computer and use it in GitHub Desktop.
Serial Promises
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
| 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