Koa is a new application framework for Node.js. Its whole point is to eliminate the callback madness that plagues many Node.js apps. It achieves this previously-impossible feat by using the powerful generators feature which is new in JavaScript ES6. Koa is built by the same people who created Express, the best-known Node.js application framework, so it’s at least worth a look.
Having written plenty of callback-heavy JavaScript, I was excited to give this thing a go and see how much simpler it could make my code.
This blog post is purely about generators and async in Koa. If you want to actually build an app with Koa, go and read the framework’s website. If you’ve never used Express (the earlier incarnation of Koa’s ideas) then be sure to learn aboutmiddleware, the central architectural pattern in Koa, so you will see how the framework intends your application to be organised.
Your new post is loading...