Skip to content

Instantly share code, notes, and snippets.

@kazu69
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu69/9501012 to your computer and use it in GitHub Desktop.
Save kazu69/9501012 to your computer and use it in GitHub Desktop.
koa.js yield order
var koa = require('koa');
var app = koa();
app.use(function *(next){
console.log(1);
yield next;
console.log(6);
});
app.use(function *(next){
console.log(2);
yield next;
console.log(5);
});
app.use(function *(next){
console.log(3);
yield next;
console.log(4);
});
// response
app.use(function *(){
console.log('add body')
this.body = 'Hello World';
});
app.listen(3000);
node --harmony example.js
1
2
3
add body
4
5
6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment