Skip to content

Instantly share code, notes, and snippets.

@toruta39
Created February 23, 2016 01:43
Show Gist options
  • Save toruta39/ae4bed69537442a80d51 to your computer and use it in GitHub Desktop.
Save toruta39/ae4bed69537442a80d51 to your computer and use it in GitHub Desktop.
Learning co
var co = require('co');
co(function* () {
var result = 0;
result = yield Promise.resolve(1);
console.log(result); // 1
result = yield Promise.resolve(result + 1);
console.log(result); // 2
return 3;
}).then(function(res) {
console.log(res); // 3
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment