Skip to content
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

A way to combine streams #14

Open
reconbot opened this issue Sep 4, 2017 · 2 comments
Open

A way to combine streams #14

reconbot opened this issue Sep 4, 2017 · 2 comments

Comments

@reconbot
Copy link
Contributor

reconbot commented Sep 4, 2017

A way to combine streams is needed. It's one of those things that should be easy to do.

The following wont work right.

const oldUsers = new OldUserStream()
const newUsers = new NewUserStream()
const countUsers = new CountUserStream()

oldUsers.pipe(countUsers)
newUsers.pipe(countUsers)

countUsers.on('end', letEveryoneKnowWereDone)

If we have more old users than new users the new users stream will end and end the count users pipe. Pipe takes an option to stop propagating the close event but then you have to manually listen for both close events and then call .end() on the destination stream. That's annoying.

The multistream package solves this by piping one stream than another. But we often want to do these operations concurrently. So merge-stream fits that bill.

Maybe this should be built into pipe? However if that's the case we need to ensure the inverse works too. (multiplexing).

bluestream.pipe([oldUsers, newUsers], buildEmails, [sendEmails, saveEmails])

I wan to keep researching prior art.

@CodeMan99
Copy link

Some other options:

I've personally used combined-stream, but also wonder if I should use something else.

@reconbot
Copy link
Contributor Author

reconbot commented Mar 5, 2018

merge2 works for other projects i've used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants