I'm having a problem getting co to resume when also changing it's context value:
var co = require( 'co' );
function *foo( next ){
console.log( 'foo yielding' );
yield next;
console.log( 'foo yielded' );
return 42;
}
var bar = co( function *(){
console.log( 'bar yielding' );
// this is the bit that I'm having problems with
yield function( cb ){
return co( foo ).call(
{ name: 'this object' }
, function(){ console.log( 'in next' ); }
, cb
);
};
console.log( 'bar yielded' );
} );
bar();
The above logs:
bar yielding
foo yielding
in next
I've tried wrapping the co( foo ).call
line in a function, a generator function, and a bunch of other things. I can't get it to work... help!
Note that if I call co
normally, it works. But then I can't set the context of, or pass arguments to, the function I'm trying to call:
yield co( foo );