Skip to content

SSEStreamingApi

reference
1 min readUpdated

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

MethodSignatureReturns
writeSSEwriteSSE(message: SSEMessage)void

Where it refuses work

  • SSEStreamingApi stops the work with Error when value && /[\r\n]/.test(value).

Diagram

mermaid
graph LR
  A[Application event] --> B[SSEStreamingApi]
  B --> C[writeSSE()]
  C --> D[SSE response stream]
  D --> E[Connected client]

Usage

ts
import { 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?

Download as PDF
SSEStreamingApi — Hono (narrator proof)