-
-
Save LincolnBurrows/42989ad0e507b03ac54bcfc91a99b674 to your computer and use it in GitHub Desktop.
thunkify&co code snippet
This file contains 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 thunkify = require('thunkify'); | |
var co = require('co'); | |
function myThunk(userName,callback){ | |
callback(null , 'hello'+' '+ userName); | |
} | |
var myR = thunkify(myThunk); | |
function* fn(){ | |
var a = yield myR('a'); | |
console.log(a); | |
return 'over' | |
} | |
var f = fn(); | |
var out = f.next(); | |
console.log(out) | |
out.value(function (err,str){console.log(str)}) | |
var out2 = f.next() | |
console.log(out2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment