Invokes run off the controller, in a proc of their own, and a connected component renders every
step: a state with an :invoke shows while its :src runs. The machine is now stepped by
taia.state-machines 0.2.7.
send-event! that enters a state with an :invoke pushes that state's render first
(render something for it: a spinner), then the state the invoke lands in. A one-shot component
that loads on open can stay as it is; a connected one can drop its skeleton + LOAD and go
straight to the invoke (example 8).:src no longer holds up a connection's flow: send-event!s that arrive while it runs
are handled meanwhile. Its :on-done comes back with the ctx it started from, so the state it
lands in should not re-render from that ctx what those events rendered since.io.github.danbunea/taia.state-machines comes in as a dependency (with the jar's pom).taia.ds.state-machines.* namespaces are gone: the state machines are that library now.
Rename the requires: taia.ds.state-machines.interface → taia.state-machines.core, and
taia.ds.state-machines.test-helpers / .interface.test-helpers →
taia.state-machines.test-helpers (test-machine is the same).:invoke, in a
cycle with the controller: the controller takes one step at a time and hands an :invoke's
:src to it; its outcome comes back as the next step. Both are taia.state-machines' flow steps
(io.github.danbunea/taia.state-machines 0.2.7, a new dependency), each :src run under the
sender's trace.:async?: a state with an :invoke
is pushed down the stream while its :src runs, then where it lands. The connect's INIT answers
with its first render; the ones after it go down the stream. One-shot events are unchanged: one
render, the last step's.live.live-weather): example 6 as a connected component. INIT
goes straight to the state with the :invoke, so the spinner answers it and the weather comes
down the stream (no skeleton, no LOAD); a server-side refresher sends REFRESH with
send-event!.:invoke proc (idle for the counters), and a third
one, connected-invoke-flow.gif, follows a connected component's INIT into a state with an
:invoke: the spinner first, the :src in :invoke, the landed state down the stream.bb dev [port] (also PORT / NREPL_PORT), in taia.ds and in the template: another port when
7788 is taken, the nREPL on the next one up. A port already in use now stops bb dev with a
message naming it and how to pick another, instead of a BindException.version in build.clj (it was 0.1.<git commit count>, so a plain
bb jar built 0.1.42 after 0.5.0). bb deploy refuses a version the README, template.edn,
the CHANGELOG and the v<version> tag on HEAD do not all agree on.state-machines brick is removed; taia.ds uses taia.state-machines for transition,
the flow steps and test-machine.domain.event/transition is replaced by machine-input / with-from-state (the
controller steps itself); fn-name moved to process-event.common.Datastar 1.0.5 (the bundled datastar.js) with the Clojure SDK 1.0.0-RC13, and three reconnect
fixes. Each fix came with a test that reproduced the bug first (e2e/tests/sse-reconnect.spec.ts,
e2e/tests/live-counter.spec.ts; helpers/connections.ts counts a page's connections).
datastar.js and sse-reconnect.js
come from the jar.started
before the replaced one's finished, so the watchdog took the replacement for a death and
reconnected 2 s later, replacing the live stream again, forever. On RC8, one ds-reconnect on a
live stream opened 5 connections in 6.5 s. sse-reconnect.js now counts in-flight fetches per
element. It also no longer reconnects twice when retries run out (retries-failed and
finished).datastar-nds-superseded event and is
closed, on a virtual thread of its own. With Datastar 1.0 this matters on one element too: a
connection re-opened with a different URL no longer cancels the old one by itself.FetchFailed pageerror, which is never ignored.sse-reconnect.js no longer claims Datastar
reopens a cleanly closed stream: it never does.data-init that moves the machine on) never arrived. Now the stream is closed, its fetch ends,
and an element carrying data-on:ds-reconnect reconnects and re-renders. See
Connected components.user-write-buffer, was 100): one burst of pushes reaches 100+
writes in a few ms, which overflowed 100 even for a healthy client./ds/nds/…. A request on /ds/nds-connect/… now always opens a connection, whatever its method and event. A click POSTed there would open a stream of its own on the button, and that stream would replace the page's connection as the one send-event! reaches.handler-connected-component-event is removed. Mount the connect handler once, on any method, and drop the :post route (a route map that still names it fails to compile, which points at the clicks to move):
["/nds-connect"
["/:component/:component-id/:event" {:handler ds/handler-connected-component-connect}]]
/ds/nds-connect/… has one job: opening a connection for send-event!. Every request there, on any method (@get or @post) and with any event, answers with an SSE stream, starts a new flow, runs its event through it, and registers stream and flow under (component-id, user), replacing and stopping whatever was there. send-event! runs server events through that flow, one after the other.handler-connected-component-event), and with it the observer's :nds-connect-event route./ds/nds/…; the examples app and the template mount nds-connect once, on any method. The template pins 0.4.0.#<cid>-mount) around #<cid>, and a connected child's mount POSTs its INIT and carries data-on:ds-reconnect, so the reconnect watchdog re-opens a dropped connection. The marker cannot sit on #<cid> itself: the render's morph drops attributes it does not produce (Gotchas). The watchdog example in Connected components had that mistake; it now uses a wrapper.send-event! goes through the connection's flow.taia/app. clojure -Tnew create :template io.github.danbunea/taia.ds%template%taia/app :name acme/shop generates a Polylith workspace with async Jetty, reitit, bb dev with an nREPL, RCF tests, poly check, an uberjar (bb uberjar), and the counter and live counter ready to edit. See docs/new-project.md. bb template-test generates a project and runs its checks. The generated project also has inline RCF tests for each action, machine and render fn, and Playwright specs for both components under the console guard (bb e2e-test).taia.ds.state-machines.interface.test-helpers/test-machine: the declarative machine runner on the interface, so a base in a Polylith workspace that has the brick can use it (poly check rejects taia.ds.state-machines.test-helpers there). taia.ds.state-machines.test-helpers stays, with the same fn.test-machine (target and action trace per state and event), and the render fn with its collaborators spied. inspect/state-pre is tested too. The live counter's REPL helpers inc! / reset! are gone: a server event from the REPL is ds/send-event! itself.A docs release: the library code is the same as 0.3.0.
doc/cljdoc.edn sets :cljdoc/languages ["clj"]. The library is JVM-only, and cljdoc's ClojureScript analysis of the .cljc interface (which requires .clj handlers) failed the whole API import, so 0.2.0 and 0.3.0 have articles but no API pages on cljdoc. 0.3.1 is the first with them.:memory (no server atom, no send-ui! broadcast). A click carries it in the signals; a server event — (ds/send-event! "live1" user "increment" {:count n}), e.g. from the REPL — sends it as params. The controller's REPL helpers inc! / reset! now take and send the count too. Its e2e spec now checks two users counting independently.send-event! step (the second covers it); the second shows the REPL sending the memory as params, with no server state.["/nds-connect"
["/:component/:component-id/:event" {:get {:handler ds/handler-connected-component-connect}
:post {:handler ds/handler-connected-component-event}}]]
process-component-event's result no longer carries :request. It keeps its signature and still returns :ctx and :html; it now throws an ex-info with ::timeout after 30 s.(ds/send-event! cid user "tick" {:remaining 4})), and handle an event that can arrive in any state on the machine's own :on (Gotchas).clojure.core.async.flow of two procs, :controller (the state machine) and :view (the render fn), between an :in-chan and an :out-chan. The machine and render fn are resolved once, when the flow is built.taia.ds.datastar.use-cases.process-event (with process-event.controller, .view and .common), the pure rules in domain.ctx and domain.event, and a new adapter, adapters.handlers.request, that turns a Ring request into the flow's message — the use case and the domain see plain data only. pipeline.clj is gone./ds/nds/…) gets a flow of its own: about 200 µs per event against 100 µs for the plain pipeline, with no thread or heap growth (proc loops run on virtual threads).handler-connected-component-event: POST /ds/nds-connect/<component>/<component-id>/<event> runs through the stream's flow and is answered with the render; without an open stream it falls back to the one-shot handler.send-event!: a server event to a connection's flow; its render is pushed down the stream. New connections: who has an open stream, {component-id [user-id …]} — look there when send-event! answers false.start-component-flow!, run-flow-event! and stop-component-flow!: drive a flow headless, e.g. to test a connected component in process.!connections entries are {:sse-gen :flow}; whoever removes an entry (on-close, a stale write, a reconnect) stops its flow.:route :nds-connect-event.live.countdown): a connected component driven by server events, with its article, spec block and e2e spec.(inc!) / (reset!), and send-event! / connections snippets.dev: start! / stop! / restart! touch only the HTTP server, never the nREPL you are connected through; a lazy user ns offers the same; Jetty logs at WARN in development.bb coverage: the unit tests under Cloverage, an HTML report in target/coverage/; bb coverage <ns-prefix> reports only those namespaces.spy/called-once-with?, values written inline, threads one step per line. 114 test blocks, 748 assertions.scripts/component_flow_svg.clj (bb component-flow-gif), and a "What you write" section.send-event! with params, the POST route, and what a server event starts from.home.home, with a controller). There is no page route any more: a GET on /ds/nds/home.home/home/init?example=<name> renders it, and start! returns that URL. layout.clj → components/home/ (the registry lives in the controller).docs/state-machines.md.datastar brick no longer ships example components: adapters.components.counter.* and html-page are gone from the jar. The discovery tests moved to the brick's test dir and define the component they resolve in memory.[] (was ["taia.ds.datastar.adapters.components"], which named nothing). Applications must call set-component-search-paths! at startup — they already had to.logging: the REPL debugging helpers debug, log->, log->> and dbg are gone; levels is private. The interface is trace, trace-when, trace-enabled?, warn, with-context, local-context, flatten-ctx, log-level, set-log-level!, safe-for-log.datastar, state-machines, logging, extensions, renamed under taia.ds.*.datastar.js (v1.0.0-RC.8) and sse-reconnect.js shipped as classpath resources under datastar/js/.examples base + projects/examples: six components (counter, live counter, signup form, wizard, TodoMVC, weather via Open-Meteo) with walkthroughs in docs/examples/ and an in-process test suite; bb dev serves them.bb e2e-test: Playwright suite against the examples app (e2e/), with a console-error guard and a two-user SSE fan-out spec.docs/img/counter-flow.svg, GIF rendered by bb flow-gif).doc/cljdoc.edn; generated docs/api.md (bb api-index).ctx->data-signals, html-response.:patch (the previous :broadcast effect was ignored by the initial-render path, so the example never rendered).Can you improve this documentation?Edit on GitHub
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 |