Fragment data shapes and the one Datastar SSE translator.
A fragment is the kernel's wire-format-neutral way of saying "push this to the browser":
{:fragment/kind :elements
:fragment/html "<form id=ix-001>…</form>"
:fragment/opts {…patch-elements! options…}}
{:fragment/kind :signals
:fragment/data {:foo 1}
:fragment/opts {}}
{:fragment/kind :script
:fragment/script "alert('hi')"
:fragment/opts {}}
{:fragment/kind :close}
The kernel never touches Datastar; it just produces these maps. This
namespace is the single Datastar SDK boundary — it owns the patch-
mode keyword translation and turns fragments into SSE events. Before
it existed, the translator was duplicated between dev.zeko.stube.http and
dev.zeko.stube.server.
Fragment data shapes and the one Datastar SSE translator.
A *fragment* is the kernel's wire-format-neutral way of saying "push
this to the browser":
{:fragment/kind :elements
:fragment/html "<form id=ix-001>…</form>"
:fragment/opts {…patch-elements! options…}}
{:fragment/kind :signals
:fragment/data {:foo 1}
:fragment/opts {}}
{:fragment/kind :script
:fragment/script "alert('hi')"
:fragment/opts {}}
{:fragment/kind :close}
The kernel never touches Datastar; it just produces these maps. This
namespace is the **single Datastar SDK boundary** — it owns the patch-
mode keyword translation and turns fragments into SSE events. Before
it existed, the translator was duplicated between [[dev.zeko.stube.http]] and
[[dev.zeko.stube.server]].Tell the SSE channel to close. Used after :end.
Tell the SSE channel to close. Used after `:end`.
(elements html)(elements html opts)Build an :elements fragment. opts is a kernel-level options map
({:selector ... :patch-mode ...}); leave it empty to let Datastar
morph by id.
Build an `:elements` fragment. `opts` is a kernel-level options map
(`{:selector ... :patch-mode ...}`); leave it empty to let Datastar
morph by id.(push! sse-gen fragments)Push a sequence of fragments to an open Datastar SSE generator, holding the SSE lock so concurrent pushes never interleave.
Push a sequence of fragments to an open Datastar SSE generator, holding the SSE lock so concurrent pushes never interleave.
(script js)Build an :execute-script fragment.
Build an `:execute-script` fragment.
(signals m)Build a :signals fragment from a Clojure map.
Build a `:signals` fragment from a Clojure map.
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 |