Brendan Eich (2013-12-08T09:13:50.000Z)
Hemanth H.M wrote:
> Streams allow the event loop to run between iterations, unlike yield, 
> that's where it gets tricky and converting a stream based logic to 
> task.js isn't straight forward. 

How about something like this?

spawn(function *() {
     var gen = this.thread;

     stream.on('data', function (data) {
           gen.send(data);
     });

     console.log(yield gen.next());
});

/be
domenic at domenicdenicola.com (2013-12-10T02:27:38.478Z)
Hemanth H.M wrote:
> Streams allow the event loop to run between iterations, unlike yield, 
> that's where it gets tricky and converting a stream based logic to 
> task.js isn't straight forward. 

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());
});
```