Kind: Class
Source: src/helper/streaming/sse.ts
Part of: Helper
SSEStreamingApi provides the Server-Sent Events streaming helper for the application. Its writeSSE() method writes data through the SSE response flow so connected clients can receive streamed updates.
Extends: StreamingApi
Methods
| Method | Signature | Returns |
|---|---|---|
writeSSE | writeSSE(message: SSEMessage) | void |
Where it refuses work
SSEStreamingApistops the work withErrorwhenvalue && /[\r\n]/.test(value).
Diagram
mermaidgraph LR A[Application event] --> B[SSEStreamingApi] B --> C[writeSSE()] C --> D[SSE response stream] D --> E[Connected client]
Usage
tsimport { SSEStreamingApi } from './helper/streaming/sse';
const sseStreamingApi = new SSEStreamingApi();
sseStreamingApi.writeSSE();
AI Coding Instructions
- Keep SSE-specific output handling inside
SSEStreamingApi. - Call
writeSSE()from code that already owns the active SSE response flow. - Preserve the event formatting expected by connected SSE clients when changing
writeSSE(). - Handle closed or unavailable response streams at the integration point.
Was this page helpful?