[]previous and next page

createSseClient

Opens an SSE stream and keeps it open: on a drop it waits (backoff, or the server's retry) and reconnects with the last event id.

Opens an SSE stream and keeps it open: on a drop it waits (backoff, or the server's retry) and reconnects with the last event id. Events arrive in order. A 4xx answer stops it (the server refused the stream, retrying would not help); a 5xx or a network error is retried.

Import#

ts
import { createSseClient } from "@shadow-js/dusk/client";

Signature#

ts
function createSseClient<T = unknown>(options: SseClientOptions<T>): SseClient

Parameters#

Name Description
options The URL, the handler and the policy.

Returns#

The client.

Examples#

ts
const feed = createSseClient({ url: "/feed", onEvent: (event) => console.log(event.data) });
feed.close();