4 ms·
Not that perfectly. You still have the question of how to represent the one-time header data.
by aphantastic 2y ago
Not that perfectly. You still have the question of how to represent the one-time header data.
- nailer 2y agoI'm imagining: yield the headers (Content-Type: text/event-stream) the first time, yield the newline-formatted event streams on subsequent yields. I haven't done it though, I used to really like SSE (it's a little more REST-y) but the world seems to have decided on websockets.
- johnny22 2y agoI think that's how it works with nestjs's observer setup with rxjs. I just return the SSE stream and it works. I use it with fastify, not express.
- aphantastic 2y agoThat could work. Probably it’d be a very easy bit of middleware/express extension to write, it’s basically just wrapping the existing writeHeader, write, end, in the hot new syntax. Probably you’d get some benefits in composability, and lose some performance in the extreme.