Liking cljdoc? Tell your friends :D

taia.ds.datastar.adapters.handlers.connected-component-handler

Handler for establishing persistent SSE connections to component instances. Manages a !connections atom that tracks, per (component-id, user-id), the open SSE stream AND the component flow (taia.ds.datastar.use-cases.process-event) that lives as long as it.

One route, any method and any event: /ds/nds-connect/<component>/<component-id>/<event>. Every request opens a connection: a new flow starts, the request's event runs through it, and its render is sent down the stream. The flow is registered with the stream under (component-id, user), replacing (and stopping) whatever was there, so a reconnect or a reload simply takes over. The registered flow is what send-event! puts server events on; their renders are pushed down the open stream. Browser events after the open belong on /ds/nds/… (one-shot): a request on the connect path would open a connection of its own. The flow keeps nothing between events.

Handler for establishing persistent SSE connections to component instances.
Manages a `!connections` atom that tracks, per (component-id, user-id), the
open SSE stream AND the component flow (`taia.ds.datastar.use-cases.process-event`)
that lives as long as it.

One route, any method and any event:
/ds/nds-connect/<component>/<component-id>/<event>. Every request opens a
connection: a new flow starts, the request's event runs through it, and its
render is sent down the stream. The flow is registered with the stream under
(component-id, user), replacing (and stopping) whatever was there, so a
reconnect or a reload simply takes over. The registered flow is what
`send-event!` puts server events on; their renders are pushed down the open
stream. Browser events after the open belong on /ds/nds/… (one-shot): a
request on the connect path would open a connection of its own.
The flow keeps nothing between events.
raw docstring

taia.ds.datastar.adapters.handlers.default-component-handler

Dynamic endpoint handler for component events. Handles routes like /:component/:component-id/:event.

The event runs through a component flow of its own (process-component-event: request → message → the process-event use case); the response shaping (render-response, error-response) lives in taia.ds.datastar.adapters.handlers.response. This namespace only owns the Ring handler entrypoint.

Dynamic endpoint handler for component events.
Handles routes like /:component/:component-id/:event.

The event runs through a component flow of its own
(`process-component-event`: request → message → the process-event use
case); the response
shaping (`render-response`, `error-response`) lives in
`taia.ds.datastar.adapters.handlers.response`. This namespace only owns the
Ring handler entrypoint.
raw docstring

taia.ds.datastar.adapters.handlers.discovery-cache

Lookup cache for Datastar component resolution.

WHAT IS CACHED: the resolved NAMESPACE SYMBOLS, never the vars.

The expensive half of discovery/discover-component is the search-path scan: for "chat.chat" an earlier prefix such as my.app.admin.components does not hold it, so require throws a FileNotFoundException (stack trace and all) before the scan falls through to my.app.components.chat.chat. That answer never changes for a given [component-name controller-name] pair, so it is what we store. Turning the cached symbols back into vars is a namespace-map lookup with no I/O, and it is done on every hit — which keeps the cache REPL-safe: caching the vars themselves would survive an ordinary defn re-evaluation (same var object, new root binding) but go stale on remove-ns / :reload-all, which mint brand-new var objects.

Deliberately NOT cache.interface: that component's contract is EDN-serializable values under a TTL, and it would add a cross-component dependency to the intentionally generic datastar component.

Lookup cache for Datastar component resolution.

WHAT IS CACHED: the resolved NAMESPACE SYMBOLS, never the vars.

The expensive half of `discovery/discover-component` is the search-path scan:
for "chat.chat" an earlier prefix such as `my.app.admin.components` does not hold it, so
`require` throws a FileNotFoundException (stack trace and all) before the scan
falls through to `my.app.components.chat.chat`. That answer never
changes for a given [component-name controller-name] pair, so it is what we
store. Turning the cached symbols back into vars is a namespace-map lookup
with no I/O, and it is done on every hit — which keeps the cache REPL-safe:
caching the vars themselves would survive an ordinary `defn` re-evaluation
(same var object, new root binding) but go stale on `remove-ns` / `:reload-all`,
which mint brand-new var objects.

Deliberately NOT `cache.interface`: that component's contract is
EDN-serializable values under a TTL, and it would add a cross-component
dependency to the intentionally generic `datastar` component.
raw docstring

taia.ds.datastar.adapters.handlers.observer

Pluggable observation hook for the two Datastar entry points (/ds/nds and /ds/nds-connect). datastar stays metrics-agnostic: it reports plain maps to ONE observer fn installed at startup (taia.ds.datastar.interface/set-observer!), and does nothing at all when none is set.

Observations:

  • {:type :event :route :nds|:nds-connect :component c :event e :outcome :ok|:error :seconds s}
  • {:type :sse-opened :component c}
  • {:type :sse-closed :component c :seconds lifetime}

No component-id is ever reported — every instance of a component is one series. And the reported values are BOUNDED: component and event come from the URL, so anyone could mint new ones. A component counts only once discovery has resolved it (the discovery cache holds it), an event only when that component's machine declares it; everything else collapses to unknown-component / other-event.

Pluggable observation hook for the two Datastar entry points
(/ds/nds and /ds/nds-connect). `datastar` stays metrics-agnostic: it
reports plain maps to ONE observer fn installed at startup
(`taia.ds.datastar.interface/set-observer!`), and does nothing at all when none is set.

Observations:
- {:type :event :route :nds|:nds-connect :component c :event e
   :outcome :ok|:error :seconds s}
- {:type :sse-opened :component c}
- {:type :sse-closed :component c :seconds lifetime}

No component-id is ever reported — every instance of a component is one
series. And the reported values are BOUNDED: component and event come
from the URL, so anyone could mint new ones. A component counts only once
discovery has resolved it (the discovery cache holds it), an event only
when that component's machine declares it; everything else collapses to
`unknown-component` / `other-event`.
raw docstring

taia.ds.datastar.adapters.handlers.request

From a Ring request to the plain event message a component's flow takes (see taia.ds.datastar.use-cases.process-event.common). This is the only place that knows where Datastar puts things in a request: the event's params, the component's slice of the signal store, the logged user.

From a Ring request to the plain event message a component's flow takes
(see `taia.ds.datastar.use-cases.process-event.common`). This is the only
place that knows where Datastar puts things in a request: the event's
params, the component's slice of the signal store, the logged user.
raw 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