Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPlease more examples! #58
Comments
This comment has been minimized.
This comment has been minimized.
timoxley
commented
Apr 24, 2014
|
@giacecco you can just write to the destination stream directly e.g. emitter.on('data', function(data) {
destination.write(data)
}) |
This comment has been minimized.
This comment has been minimized.
giacecco
commented
Apr 25, 2014
|
Ok but which of event-stream's objects is ideal for 'destination', considering that the event generates data in many events? Moreover, I guess I need to use .pause() and .resume() between one event and another if I want destination to understand that the input stream has not finished, or I did not get how that works too? In general, if not by experimenting with streams, what can one learn about it before fiddling with event-stream? This info would be useful to be at the top of the README.md for people who gets to your library without having enough experience of the model. G. |
This comment has been minimized.
This comment has been minimized.
giacecco
commented
Apr 25, 2014
|
It looks like I may have solved with something that looks like below:
Apparently there is no need for using pause, actually doing that causes a Nodejs warning:
It is clear I am still missing the point of how event-stream works, this feels too much like magic :-) G. |
This comment has been minimized.
This comment has been minimized.
timoxley
commented
Apr 25, 2014
|
Where is this data coming from? What is You can just write directly to your writable stream: var outStream = require('fs').createWriteStream('foo.txt')
var emitter = new Emitter(function (data) {
outStream.write(data);
}); |
This comment has been minimized.
This comment has been minimized.
timoxley
commented
Apr 25, 2014
|
@giacecco if you want to master this stuff, you should start by doing stream-adventure: http://nodeschool.io/#stream-adventure |
giacecco commentedApr 24, 2014
Dear dominctarr,
Thank you for your work with event-stream, I have been using it for a few days now but still feel like I am just scraping the surface. There are things that I am sure are feasible using event-stream, but the documentation is not sufficient for me to understand how to put the pieces together. Please provide more examples with it!
My current issue in particular is that I need to transform a series of 'events' into a readable stream. The code should look something like the one below, where 'Emitter' is the constructor for a third-party object calling the function I give as a parameter every time there is new data to process.
Can you give me a hint? Thanks,
Giacecco