JS interop — DOM, fetch, localStorage from cljrs
The cljrs runtime lives entirely in WASM. The cljrs.js
namespace exposes browser primitives — console.log,
document.getElementById, addEventListener,
localStorage, fetch — as ordinary cljrs
builtins. DOM elements round-trip as opaque handles.
Click counter
0
Dad joke (icanhazdadjoke.com)
— click the button —
TODO list (persisted in localStorage)
loading…
Edits apply automatically (debounced ~300ms). The cljrs source owns all the wiring: it grabs DOM nodes, attaches listeners, and reads/writes localStorage.
Builtins
(js/log msg ...)—console.log(js/now)—Date.now()(ms since epoch)(js/get-element id)— opaque handle ornil(js/set-text! el s)·(js/set-html! el s)(js/on! el "click" handler)— handler is a 0-arg cljrs fn(js/local-get k)·(js/local-set! k s)(js/fetch-text url callback)— callback receives the body string (or nil on error)