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

    Class SSEClient

    SSE client that connects to a text/event-stream endpoint and yields events.

    Supports automatic reconnection with exponential backoff + jitter, Last-Event-ID resumption, heartbeat detection, and configurable validation.

    Index

    Constructors

    Accessors

    • get url(): string

      The SSE endpoint URL.

      Returns string

    • get closed(): boolean

      Whether the client has been closed.

      Returns boolean

    • get streamHealth(): Readonly<SSEStreamHealth>

      Snapshot of current stream health (events, reconnects, last event time).

      Returns Readonly<SSEStreamHealth>

    Methods

    • Listen for a specific event type (like EventSource.addEventListener). Returns an async iterator that yields only matching events.

      Parameters

      • eventType: string

      Returns AsyncGenerator<SSEEvent>

    • Collect all events into an array until the stream closes.

      Use with caution on long-lived streams — for infinite streams, prefer the async iterator interface (for await...of).

      Parameters

      • options: { limit?: number; signal?: AbortSignal } = {}
        • Optionallimit?: number

          If provided, stops collecting after this many events. Returns early with partial results.

        • Optionalsignal?: AbortSignal

          AbortSignal to cancel collection early.

      Returns Promise<SSEEvent[]>

      Array of collected events. Returns empty array if stream ends with no events.

    • Close the connection and abort any active stream.

      Returns void

    • Destroy the client and clean up all resources.

      Returns void