Brendan Eich (2013-12-08T09:41:14.000Z)
domenic at domenicdenicola.com (2013-12-10T02:28:03.723Z)
Brendan Eich wrote: > How about something like this? > > ```js > 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: ```js 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.