Skip to content

Commit caacc57

Browse files
committed
修改generator
1 parent 4ee9fa0 commit caacc57

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

docs/generator.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,12 @@ function* longRunningTask() {
754754
scheduler(longRunningTask());
755755

756756
function scheduler(task) {
757-
setTimeout(function () {
758-
if (!task.next(task.value).done) {
759-
scheduler(task);
757+
setTimeout(function() {
758+
var taskObj = task.next(task.value);
759+
// 如果Generator函数未结束,就继续调用
760+
if (!taskObj.done) {
761+
task.value = taskObj.value
762+
scheduler(task);
760763
}
761764
}, 0);
762765
}

0 commit comments

Comments
 (0)