kinetex - v1.0.0-rc.1
    Preparing search index...

    Class SSEServerResponse

    Builder for creating SSE-compatible server responses. Works with any runtime that supports the WHATWG Streams API.

    Index

    Constructors

    Properties

    stream: ReadableStream<string>

    The underlying readable stream for writing SSE events.

    Accessors

    • get closed(): boolean

      Whether the underlying stream has been closed.

      Returns boolean

    Methods

    • Send a comment (heartbeat ping).

      Parameters

      • text: string = ""

      Returns this

    • Send a "message" event.

      Parameters

      • data: string
      • options: { id?: string; retry?: number } = {}

      Returns this

    • Send a named event.

      Parameters

      • event: string
      • data: string
      • options: { id?: string; retry?: number } = {}

      Returns this

    • Send a typed JSON event.

      Type Parameters

      • T

      Parameters

      • event: string
      • data: T
      • options: { id?: string } = {}

      Returns this

    • Send a heartbeat comment to keep the connection alive.

      Returns this

    • Tell the client to reconnect after ms milliseconds.

      Parameters

      • ms: number

      Returns this

    • Build a standard SSE HTTP Response object.

      Parameters

      • headers: Record<string, string> = {}

        Additional HTTP headers to merge with the SSE defaults.

      Returns Response

      A Response with content-type text/event-stream.