Skip to content

A way to combine streams #14

@reconbot

Description

@reconbot

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions