Open axkibe opened 10 years ago
BTW: suspend is great! After trying various approaches the last years, I'm currently settling on this :-)
@axkibe Happy to hear suspend is working well for you, and thanks for saying so!
I think your idea for named forks is a good one, and I can't think of any other obvious use for a single string parameter to fork()
. Let me stew it over for a little bit, but initially I like it.
I gave some more thought about this, and I think there might be better ways than using join, if its implementable ( i don't know :-) something like this would be awesome:
var
sus = require( 'suspend' ),
a = sus( fs.readFile( 'a.txt', sus.callback() ),
b = sus( fs.readFile( 'b.txt', sus.callback() );
try
{
console.log( yield a.data( ) );
console.log( yield b.data( ) );
}
catch ( err )
{
/// error handler
}
I'd wish I could call fork with names.
Would give nice code rather than counting fork
Additionally not an issue but a question. Say I got a generator which wants to runs two generators in parallel - that is starting the second generator when the first one yields. Then waits until both are finished. How'd one approach this?