Created
September 26, 2014 01:28
-
-
Save ryanking8215/e0278be41de8da06a114 to your computer and use it in GitHub Desktop.
[Promise] 使用递归,按顺序迭代数组异步任务
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
var array = ['a1','a2','a3','a4'] | |
return (function handle_array(idx){ | |
idx = idx || 0 | |
if (idx>=array.length) { | |
return | |
} | |
return async_task(id,array[idx]) | |
.then(function(result){ | |
idx++; | |
return handle_array(idx); | |
}) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment