MatthewWid / better-sse

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

Session data buffer #43

Closed MatthewWid closed 2 years ago

MatthewWid commented 2 years ago

Resolves #35.

This PR adds a data buffer that buffers written data and only sends it to the client when the flush method is called.

In addition, the behaviour of the dispatch method has been split into two different methods: dispatch, only writing a newline, and flush that flushes the buffer data to the client and clears the buffer.

This is a breaking change to the public API and will be released in the next 0.x.0 release.