Liking cljdoc? Tell your friends :D

wagoe.realtime.shell.handlers.sse

Server-sent events for htmx: sse-handler streams, push-fragment! pushes. See the realtime guide for the route, page and push example.

Server-sent events for htmx: `sse-handler` streams, `push-fragment!` pushes.
See the realtime guide for the route, page and push example.
raw docstring

push-fragment!clj

(push-fragment! realtime-service topic fragment)
(push-fragment! realtime-service topic fragment {:keys [event]})

Render fragment (Hiccup or an HTML string) for every stream subscribed to topic and send it as SSE event :event (default "message", what sse-swap="message" listens for). Elements carrying :hx-swap-oob swap by id, so one push can update several places. Goes over the bus, so other replicas' subscribers get it too; keep the fragment plain data.

Render `fragment` (Hiccup or an HTML string) for every stream subscribed to
`topic` and send it as SSE event `:event` (default "message", what
`sse-swap="message"` listens for). Elements carrying `:hx-swap-oob` swap
by id, so one push can update several places. Goes over the bus, so other
replicas' subscribers get it too; keep the fragment plain data.
sourceraw docstring

sse-handlerclj

(sse-handler
  realtime-service
  &
  {:keys [authorize-topic heartbeat-ms queue-size max-topics revalidate]
   :or {authorize-topic (constantly false) heartbeat-ms 15000 max-topics 16}})

Ring handler that opens an SSE stream on the topics named by ?topic= (repeatable). Needs a signed-in :user; every topic must pass :authorize-topic, and without one every topic is refused.

Each open stream holds a server thread; the service caps them per node (:max-streams), and a stream over the cap is told to retry in 10 s.

Options: :authorize-topic (fn [request topic]) -> truthy to allow :revalidate (fn [request]) -> truthy while the session is still good; asked every heartbeat, the stream closes when it fails :heartbeat-ms comment line interval, default 15000 :queue-size events buffered per client before it is dropped, default 256 :max-topics topics per stream, default 16

Ring handler that opens an SSE stream on the topics named by `?topic=`
(repeatable). Needs a signed-in `:user`; every topic must pass
`:authorize-topic`, and without one every topic is refused.

Each open stream holds a server thread; the service caps them per node
(`:max-streams`), and a stream over the cap is told to retry in 10 s.

Options:
  :authorize-topic (fn [request topic]) -> truthy to allow
  :revalidate      (fn [request]) -> truthy while the session is still good;
                   asked every heartbeat, the stream closes when it fails
  :heartbeat-ms    comment line interval, default 15000
  :queue-size      events buffered per client before it is dropped, default 256
  :max-topics      topics per stream, default 16
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close