koa-sse-stream
koa sse(server side event) middleware , use stream programming model
Install
npm install --save koa-sse-stream
Usage
const Koa = ;const compress = ;const sse = ; const app = ;// !!attention : if you use compress, sse must use after compress app /** * koa sse middleware * @param * @param * @param * @param * @param */app; app;
ctx.sse
a writable stream
ctx.sse.send(data)
/** * Event `close` Triggered when an SSE connection is closed, whether the server is actively closed or the client is closed *//** * * @param * @param * @param * @param * @param * @param * @param * @param */
ctx.sse.sendEnd(data)
/** * * @param * @param * @param * @param * @param * @param * @param * @param */
Attention !!!
if you use compress, sse must use after compress