Created
February 23, 2016 01:43
-
-
Save toruta39/ae4bed69537442a80d51 to your computer and use it in GitHub Desktop.
Learning co
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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