Liking cljdoc? Tell your friends :D

taia.ds.datastar.interface


connectionsclj

(connections)

The open SSE streams, as {component-id [user-id …]}: who send-ui! and send-event! can reach right now. When send-event! returns false, look here — the stream is registered under the :user/id of the request that opened it.

The open SSE streams, as {component-id [user-id …]}: who `send-ui!` and
`send-event!` can reach right now. When `send-event!` returns false,
look here — the stream is registered under the `:user/id` of the
request that opened it.
sourceraw docstring

ctx->data-signalsclj

(ctx->data-signals ctx)

The data-signals attribute value for a component's root element: the component's :memory plus :state, namespaced under its component-id, as JSON. Datastar sends this store back with every @post/@get, which is how :memory round-trips between requests. Pure; never throws.

The `data-signals` attribute value for a component's root element: the
component's `:memory` plus `:state`, namespaced under its component-id, as
JSON. Datastar sends this store back with every @post/@get, which is how
`:memory` round-trips between requests. Pure; never throws.
sourceraw docstring

handler-component-eventclj

Ring handler for dynamic component events (/ds/nds/<component>/<component-id>/<event>): discovers the component + controller, runs the FSM transition, renders the response.

Ring handler for dynamic component events (/ds/nds/<component>/<component-id>/<event>):
discovers the component + controller, runs the FSM transition, renders the response.
sourceraw docstring

handler-connected-component-connectclj

Async Ring handler that opens an SSE connection for a connected component and registers it so send-ui! can push updates to that client.

Async Ring handler that opens an SSE connection for a connected component
and registers it so `send-ui!` can push updates to that client.
sourceraw docstring

handler-connected-component-eventclj

Ring handler (both arities) for an event POSTed to a connected component's path (/ds/nds-connect/<component>/<component-id>/<event>). The event runs through the component flow that lives with the user's open stream, so it transitions from the ctx that flow holds, and the POST is answered with the render like a default component's. Without an open stream it falls back to handler-component-event.

Ring handler (both arities) for an event POSTed to a connected component's
path (/ds/nds-connect/<component>/<component-id>/<event>). The event runs
through the component flow that lives with the user's open stream, so it
transitions from the ctx that flow holds, and the POST is answered with the
render like a default component's. Without an open stream it falls back to
`handler-component-event`.
sourceraw docstring

html-responseclj

(html-response hiccup)

Ring 200 text/html response for hiccup — e.g. the full-page render that process-component-event returns for a GET at a canonical URL.

Ring 200 text/html response for `hiccup` — e.g. the full-page render that
`process-component-event` returns for a GET at a canonical URL.
sourceraw docstring

process-component-eventclj

(process-component-event req
                         component-name
                         component-id
                         event-name
                         controller-name)

Runs one event through a per-request component flow in-process (discovery → :controller FSM transition → :view render) and returns the result map with :html (hiccup or effects list) and :ctx. Throws what a step threw, or an ex-info after the event timeout. Lets a caller serve a component's full-page render at a canonical URL (e.g. GET /es → site.landing INIT) instead of redirecting into /ds/…

Runs one event through a per-request component flow in-process
(discovery → :controller FSM transition → :view render) and returns the
result map with :html (hiccup or effects list) and :ctx. Throws what a
step threw, or an ex-info after the event timeout.
Lets a caller serve a component's full-page render at a canonical URL
(e.g. GET /es → site.landing INIT) instead of redirecting into /ds/…
sourceraw docstring

run-flow-event!clj

(run-flow-event! component-flow req event-name)
(run-flow-event! component-flow req event-name params)

Runs one event through a flow from start-component-flow! and returns its result map (:ctx, :html, …). req carries the client signals and params like a request would; nil makes it a server event, with params (what send-event! sends) as its params.

Runs one event through a flow from `start-component-flow!` and returns
its result map (:ctx, :html, …). `req` carries the client signals and
params like a request would; nil makes it a server event, with
`params` (what `send-event!` sends) as its params.
sourceraw docstring

send-event!clj

(send-event! component-id user-id event-name params)

Sends a server event to the connected component (component-id, user-id): it runs through that connection's component flow — transitioning from the ctx the flow holds — and the render is pushed down the open SSE stream. event-name is case-insensitive like a URL event; params is the event's params map. Returns true when queued, false when that user has no open connection under component-id.

Sends a server event to the connected component (component-id, user-id):
it runs through that connection's component flow — transitioning from
the ctx the flow holds — and the render is pushed down the open SSE
stream. `event-name` is case-insensitive like a URL event; `params` is
the event's params map. Returns true when queued, false when that user
has no open connection under component-id.
sourceraw docstring

send-ui!clj

(send-ui! component-id user-id component-responses)

Puts component-responses onto the UI channel for async delivery to the SSE client identified by component-id and user-id.

Puts component-responses onto the UI channel for async delivery to
the SSE client identified by component-id and user-id.
sourceraw docstring

set-component-search-paths!clj

(set-component-search-paths! paths)

Sets the ordered list of namespace prefixes used to resolve components. Call once at startup with the value from app-config.

Sets the ordered list of namespace prefixes used to resolve components.
Call once at startup with the value from app-config.
sourceraw docstring

set-observer!clj

(set-observer! f)

Installs f as the observer of component events on /ds/nds and /ds/nds-connect (nil removes it). f receives plain maps — {:type :event :route :component :event :outcome :seconds}, {:type :sse-opened :component}, {:type :sse-closed :component :seconds} — with bounded labels and no component-id. See taia.ds.datastar.adapters.handlers.observer.

Installs `f` as the observer of component events on /ds/nds and
/ds/nds-connect (nil removes it). `f` receives plain maps —
{:type :event :route :component :event :outcome :seconds},
{:type :sse-opened :component}, {:type :sse-closed :component :seconds} —
with bounded labels and no component-id. See
`taia.ds.datastar.adapters.handlers.observer`.
sourceraw docstring

start-component-flow!clj

(start-component-flow! opts)

Starts a component's flow headless — no SSE stream: the machine and render fn are resolved now, like a connected component's flow. Drive it with run-flow-event!; stop it with stop-component-flow!. Useful to test a connected component in process. opts: {:component-name :component-id :controller-name}

Starts a component's flow headless — no SSE stream: the machine and
render fn are resolved now, like a connected component's flow. Drive it
with `run-flow-event!`; stop it with `stop-component-flow!`. Useful to
test a connected component in process.
opts: {:component-name :component-id :controller-name}
sourceraw docstring

stop-component-flow!clj

(stop-component-flow! component-flow)

Stops a flow from start-component-flow!.

Stops a flow from `start-component-flow!`.
sourceraw docstring

warm-component-cache!clj

(warm-component-cache! component-names)

Pre-resolves the given Datastar components into the discovery cache so the first HTTP request for one does not pay the namespace-load cost on the request thread. Entries are component names ("chat.chat") or [component-name controller-name] pairs. Never throws; returns {:warmed n :failed [...] :elapsed-ms n}. Call AFTER set-component-search-paths! — setting the paths clears the cache.

Pre-resolves the given Datastar components into the discovery cache so the
first HTTP request for one does not pay the namespace-load cost on the
request thread. Entries are component names ("chat.chat") or
[component-name controller-name] pairs. Never throws; returns
{:warmed n :failed [...] :elapsed-ms n}.
Call AFTER `set-component-search-paths!` — setting the paths clears the cache.
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