MatthewWid / better-sse

⬆ Dead simple, dependency-less, spec-compliant server-sent events implementation for Node, written in TypeScript.
MIT License
488 stars 14 forks source link

Add support for streams. #9

Closed MatthewWid closed 3 years ago

MatthewWid commented 3 years ago

Add support for giving a readable stream to the Session to pipe the stream data to the client via separate SSE events or individual data fields one after another as part of the same event.

One consideration here might be that this behaviour would be difficult to combine with the Session#data method as the user may want to know when the stream has finished piping, and thus returning something like a promise to indicate that it is done would mean that the method would no longer return the Session instance and would not be chainable with other methods anymore.

Alternatively, a completely separate method could be added (eg, Session#stream) that takes in only a stream and returns a promise to indicate when the stream has finished completing, though this also would not be chainable with other methods.