From c6dc504ce8bbfcd1b8e98ea711a734e81e3382e1 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Mon, 2 Sep 2013 19:05:49 -0700 Subject: [PATCH] docs --- docs/guide.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/guide.md b/docs/guide.md index 9a6a41d..9c08c45 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -20,8 +20,7 @@ function responseTime(next){ app.use(responseTime); ``` - If you're a front-end developer you can think any code before `yield next;` as the "capture" phase, - while any code after is the "bubble" phase. Here's another way to write the same thing, inline: + Here's another way to write the same thing, inline: ```js app.use(function(next){ @@ -34,6 +33,12 @@ app.use(function(next){ }); ``` + If you're a front-end developer you can think any code before `yield next;` as the "capture" phase, + while any code after is the "bubble" phase. This crude gif illustrates how ES6 generators allow us + to properly utilize stack flow to implement request and response flows: + +![koa middleware](https://i.cloudup.com/N7L5UakJo0.gif) + Next we'll look at the best practices for creating Koa middleware. ## Middleware Best Practices