MatthewWid/better-sse

Add support for streams.

MatthewWid opened this issue · 0 comments

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.