Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Yield

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 Yield

Lightning talk.
How Generators and Co can make asynchronous code look better.
Where to use it - from Co to Koa.

Avatar for krzychukula

krzychukula

October 29, 2015
Tweet

More Decks by krzychukula

Other Decks in Programming

Transcript

  1. co(function *(){ var username = yield getUsername() var user =

    yield getUser(username) //use username and user })
  2. Co

  3. co(function *(){ var username = yield getUsername() var user =

    yield getUser(username) //use username and user })
  4. co(function *(){ var username = “janek” var user = yield

    getUser(username) //use username and user })
  5. Koa

  6. var koa = require('koa'); var app = koa(); app.use(function *(){

    this.body = 'Hello World'; }); app.listen(3000);