-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
streamx.pipe()
does not add a listener for data
event.
#16
Comments
I think we need a new API for that. streamx explicitly does not use data listeners for pumping as it makes it much faster to avoid that internally. If we added more events would that help? |
To make my events more clear, I suggest we add:
In addition to the |
This Has there been any communication about this module with node.js streams / readable-stream maintainers? I feel like their opinion on this question would be more valuable than my own. |
I'm one of the maintainers of those. The idea with streamx isn't to be 100% compat, but to break compat if it means we can massively simplify/perf boost. That's why pipe is different along with other tweaks. We can probably add more explicit events to Node.js streams though. I'll make an issue for that on Node. |
Sounds great, I just wanted to make sure I gave the "my opinion isn't the best" qualifier to my statement that the two new events seem reasonable to me. |
@coreyfarrell reading into your examples more, is this about knowing when the stream is being piped or when it is "flowing", ie. reading internally? |
We're trying to know when the argument given to Example 1: if (pipeOut) {
input1
.pipe(toThrough(input2))
.pipe(writeable)
} else {
input1
.pipe(toThrough(input2))
.on('data', gotChunk)
} Example 2: if (pipeOut) {
toThrough(input2)
.pipe(writeable)
} else {
toThrough(input2)
.on('data', gotChunk)
} In example 1 the In example 2 there is nothing being piped in. When we detect a listener to |
Hey all, what's the status on this? |
We added pipe/piping so you can do it like this now: stream.on('newListener', function (name) {
if (name === 'data') onflowing()
})
stream.once('piping', function () {
onflowing()
})
function onflowing () {
console.log('stream is flowing now...')
} |
If the above is fine with y'all, we could potentially add a helper for that also streamx.isFlowing(stream) // true, false
streamx.flowing(stream, cb) |
@mafintosh thanks for adding the new events. Sorry I haven't been about to give feedback / testing yet, life has pulled me in other directions for now. @phated TBH it's going to early next year before I'm able to put any serious effort into any open source code. In addition to current work commitments I am in the process of a long distance move. I have not forgotten about gulp and plan to work towards getting things migrated to streamx but I want to give reasonable expectation based on my schedule. |
@mafintosh I can't speak for others but I don't see myself using a If |
Ya helper sounds like a good idea I agree |
I believe I want a if (stream._readableState.pipeTo) {
return;
} |
we fixed this |
streamx.pipe(dest)
does not attach adata
listener to streamx as stream v3 does. My goal is to migrateto-through
fromthough2
tostreamx.Transform
, to do this I need to be able to know when streamx is piped to or from.Stream code sometimes watches for the
newListener
event withdata
orreadable
for the argument.Examples:
https://github.com/mcollina/cloneable-readable/blob/f6bbe0a9da6561af84ec14ca1bc75c37c455f11c/index.js#L23-L38
https://github.com/gulpjs/to-through/blob/552d17efd3f9469166bc87832e77e86602850828/index.js#L34-L43
I'm not sure if it would be appropriate for
ReadableState#pipe
to callthis.stream.emit('newListener', 'data')
directly.Related to #14
The text was updated successfully, but these errors were encountered: