var koa = require('koa');
var app = koa();
app.use(function*(next) {
this.body = '1';
yield next; //下一步是哪一个 generator函数?当前还是下一个gen函数的第一个yield?
this.body += '5';
yield next;
this.body += '6';
console.log(this.body);
});
app.use(function*(next) {
this.body += '2';
yield next;
this.body += '4';
yield next;
this.body += 'x'
});
app.use(function*(next) {
this.body += '3';
});
app.listen(3000);
首先执行每一个generator函数的第一个yield(一个gen里有多个yield ),等执行到结束后,再返回按generator函数的倒序向上执行,每个generator函数内的yield再按从上到下的顺序执行?这样理解对吗?
这里有先进后出的规则没有?
看图便知~
