You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
testThunk's callback is called by co (systematically)
You should return thunk's result to use this in co's then.
Modified source below.
let co = require('co');
let Thunk = require('thunkify');
function testThunk(arg1, arg2, callback) {
console.log(arg1, arg2);
setTimeout(()=> {
callback(null, 'thunk test');
}, 200);
}
co(function *() {
var result = yield Thunk(testThunk)('arg1', 'arg2');
console.log(`testThunk's result : ${result}`);
return result;
}).then(result => {//The then-function called before than thunkify function,is that right?
console.log('co result:', result);
});
let co = require('co');
let Thunk = require('thunkify');
function testThunk(arg1, arg2, callback) {
console.log(arg1, arg2);
setTimeout(()=> {
callback('', 'thunk test');
}, 200);
}
co(function *() {
return Thunk(testThunk)('arg1', 'arg2')((err, data)=> { //return a thunkify function.
console.log('thunk call result:', data);
});
}).then(result=> {//The then-function called before than thunkify function,is that right?
console.log('co result:', result);
}
);
The text was updated successfully, but these errors were encountered: