Skip to content

How to implement such case ? #56

@MarcWeber

Description

@MarcWeber
const list =  range(1,100)
const stream = new Stream()
const add_to_stream = async () => {
  stream.write(something)
  stream.end() // would end for all other users
}
Promise.all(list.map( x => add_to_stream()))

The most simple way would be having end() only end the stream if a new refcounting per stream would turn 0.

Then code would look like

stream.addRefCounter(list.length)
Promise.all() ...

And it would just do what it should. Am I missing something ?
Thus default refcount should be 1.

I am unsure what should be done about error and endedResult. Allow a list to be built up internally?
What should result() be returning then ? A list ? Would break code. Add resultMany() returning all ?
I don't use result in my use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions