Brendan Eich (2013-12-08T05:11:03.000Z)
Hemanth H.M wrote:
> Yes, that's where I'm stuck.
>
> Here are the few variations I tired :
>
> ```
> function* FileReader(){
>     // Some stream code on node;
>     stream.on('data',yield function*(data) {
>           yield data;
>     });
> }

Please notice that stream.on, or any event emitter.on in Node.js, will 
set an event listener callback to be called later, the generator 
function activation in which you call stream.on will have returned 
already. You want to use something like task.js here. See 
http://taskjs.org/.

/be
domenic at domenicdenicola.com (2013-12-10T02:27:22.497Z)
Hemanth H.M wrote:
> Yes, that's where I'm stuck.
>
> Here are the few variations I tired :
>
> ```
> function* FileReader(){
>     // Some stream code on node;
>     stream.on('data',yield function*(data) {
>           yield data;
>     });
> }
> ```

Please notice that stream.on, or any event emitter.on in Node.js, will 
set an event listener callback to be called later, the generator 
function activation in which you call stream.on will have returned 
already. You want to use something like task.js here. See 
http://taskjs.org/.