Hi all,
I am playing around with streams V2 and I was wondering whether it is
possible to get the following example working somehow:
//
// Reading stuff
//
var ReadingStuff = function() {
this._data = [1, 2, 3, 4, 5];
stream.Readable.call(this);
};
util.inherits(ReadingStuff, stream.Readable);
ReadingStuff.prototype._read = function() {
if(0 === this._data.length) {
this.push(null);
return;
}
this.push(this._data[0].toString());
this._data.shift();
};
//
// Writing stuff
//
var WritingStuff = function() {
stream.Writable.call(this);
this.on('finish', function() {
console.log('Finished writing stuff!!');
});
};
util.inherits(WritingStuff, stream.Writable);
WritingStuff.prototype._write = function(chunk, encoding, next) {
console.log(chunk.toString(encoding));
next();
};
//
// Application
//
var readingStuff = new ReadingStuff();
var writingStuff = new WritingStuff();
readingStuff.pipe(writingStuff);
process.nextTick(function() {
var readingStuff2 = new ReadingStuff();
readingStuff2.pipe(writingStuff);
});
I have two different read streams that I want to pipe to a single write
stream on separate iterations of the event loop (suppose I implement the
write stream as a singleton in my application). What I see is that the
output of the first read stream is written to the write stream and when it
is done, the 'finish' event is called. The output of the second stream is
completely ignored.
Is there a way to write the output of the second read stream to the write
stream?
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.