SSE listener for the Synthigy CLJS client.
Uses fetch streaming (ReadableStream + TextDecoder) — supports
Authorization headers, matches sdk/js. Callback-driven: caller
provides on-event; listen returns a 0-arg stop function that
aborts the connection.
Auto-reconnects with Last-Event-ID + exponential backoff (1s → 30s).
SSE listener for the Synthigy CLJS client. Uses fetch streaming (ReadableStream + TextDecoder) — supports Authorization headers, matches sdk/js. Callback-driven: caller provides `on-event`; `listen` returns a 0-arg `stop` function that aborts the connection. Auto-reconnects with Last-Event-ID + exponential backoff (1s → 30s).
(listen on-event)(listen on-event
{:keys [max-delay on-parse-error on-connect on-error]
:or {max-delay 30000
on-parse-error default-on-parse-error
on-error default-on-error}})Stream SSE notifications from /data/events, calling on-event with
each {:type :entity :relations :xids} notification.
Returns a 0-arg function that stops the listener (aborts the fetch, halts reconnect loop).
Options: :max-delay — cap for reconnect backoff ms (default 30000) :on-parse-error — (fn [error raw]) for malformed frames (default logs to console.warn) :on-connect — (fn [stream-id]) called after every successful (re)connect with that connection's fresh stream id — POST the subscription set for it here. Exceptions are swallowed. :on-error — (fn [error]) for a refusal that ends the listener (default logs to console.error)
UNAUTHORIZED, FORBIDDEN and any 403 end the listener (no reconnect); other transport errors trigger reconnect with backoff.
Stream SSE notifications from /data/events, calling `on-event` with
each `{:type :entity :relations :xids}` notification.
Returns a 0-arg function that stops the listener (aborts the fetch,
halts reconnect loop).
Options:
:max-delay — cap for reconnect backoff ms (default 30000)
:on-parse-error — (fn [error raw]) for malformed frames
(default logs to console.warn)
:on-connect — (fn [stream-id]) called after every successful
(re)connect with that connection's fresh stream id —
POST the subscription set for it here. Exceptions
are swallowed.
:on-error — (fn [error]) for a refusal that ends the listener
(default logs to console.error)
UNAUTHORIZED, FORBIDDEN and any 403 end the listener (no reconnect);
other transport errors trigger reconnect with backoff.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |