mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-28 21:32:20 +00:00
修改generator
This commit is contained in:
parent
4ee9fa07d9
commit
caacc57d9f
@ -754,9 +754,12 @@ function* longRunningTask() {
|
|||||||
scheduler(longRunningTask());
|
scheduler(longRunningTask());
|
||||||
|
|
||||||
function scheduler(task) {
|
function scheduler(task) {
|
||||||
setTimeout(function () {
|
setTimeout(function() {
|
||||||
if (!task.next(task.value).done) {
|
var taskObj = task.next(task.value);
|
||||||
scheduler(task);
|
// 如果Generator函数未结束,就继续调用
|
||||||
|
if (!taskObj.done) {
|
||||||
|
task.value = taskObj.value
|
||||||
|
scheduler(task);
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user