1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-06-03 10:17:11 +00:00

修改generator

This commit is contained in:
Ruan Yifeng 2015-02-16 18:47:46 +08:00
parent 4ee9fa07d9
commit caacc57d9f

View File

@ -755,7 +755,10 @@ scheduler(longRunningTask());
function scheduler(task) { function scheduler(task) {
setTimeout(function() { setTimeout(function() {
if (!task.next(task.value).done) { var taskObj = task.next(task.value);
// 如果Generator函数未结束就继续调用
if (!taskObj.done) {
task.value = taskObj.value
scheduler(task); scheduler(task);
} }
}, 0); }, 0);