sse.ts
Source: sdks/typescript/packages/sdk/src/sse.ts. Back to the TypeScript SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Interface SSEMessage
One Server-Sent Events message: event name, data, id and retry.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
event | string | yes | Event name, message when the stream gives none. |
data | string | yes | Raw text of the data lines of the event, joined by newlines. |
id | string | no | Value of the last id field. |
retry | number | no | Reconnection delay in milliseconds from the retry field. |
Class SSEParser
Incremental Server-Sent Events parser. Feed it arbitrary text chunks (they may split lines, fields or even CRLF pairs) and it returns the complete messages seen so far.
SSEParser.end
end(): SSEMessage[]
Flushes a trailing message when the stream ends without a blank line.
This element takes no parameter.
Returns: SSEMessage[]. The last messages, possibly empty.
SSEParser.push
push(chunk: string): SSEMessage[]
Adds a text chunk and returns the messages it completes.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
chunk | string | yes | Text chunk of the stream, cut anywhere. |
Returns: SSEMessage[]. Messages completed by a blank line in this chunk.