Brendan Eich wrote:
How about something like this?
spawn(function *() {
var gen = this.thread;
stream.on('data', function (data) {
gen.send(data);
});
console.log(yield gen.next());
});
Sorry, a generator instance can't next itself, so that last statement
should be:
console.log(yield undefined);
We just need to park the task before console.log is invoked, such that
the data the listener receives is sent to the paused task's generator
and becomes theactual argument to console.log.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss