Liking cljdoc? Tell your friends :D

vaelii.browser.reload

The development browser's source reloader, which only scripts/start-vaelii-dev.sh turns on (vaelii.browser.web/dev-repl). Before each request it reloads every watched source file that changed since the last request, together with every loaded namespace that requires one of them, transitively, in dependency order.

A protocol, record, type or interface is never redefined. Re-evaluating a defprotocol defines a new interface and empties the protocol's extension map, and re-evaluating a defrecord, deftype or definterface defines a new class, so a KB loaded before the reload would hold values the reloaded code no longer recognizes. A reload therefore loads a file form by form and leaves out each of those forms whose protocol or class already exists; every other form is evaluated. A record keeps its methods inline, where protocol dispatch is a direct interface call, and a method that calls a function reaches the reloaded function through its var. An edit inside such a form is not loaded: restart-owed names it until the process restarts, and the page shows that list. A form for a class that does not exist yet is evaluated.

A held namespace is never re-evaluated at all. A namespace whose ns symbol carries :clojure.tools.namespace.repl/load false holds protocols and method-less records (vaelii.impl.types.*, vaelii.impl.protocols, …). An edit to one reloads nothing on its account, and restart-owed names it.

Form by form, not tools.namespace's refresh. refresh removes each namespace with remove-ns before it loads the file again, which re-evaluates every defonce in it and empties the state a loaded KB keeps there: the cache registry, the change feed's listeners, the thaw guard's installed readers. Loading into the existing namespace keeps a defonce's value, as require :reload does.

Only loaded namespaces reload. A dependent this process never loaded, such as an LLM provider the browser has not reached, stays unloaded: loading it would run code the running server does not use.

tools.namespace ships in the :dev profile only, so its dependency graph and ns-form reader are resolved when wrap-reload builds the reloader, never at this namespace's load. The standalone jar compiles this namespace and has no tools.namespace.

The development browser's source reloader, which only `scripts/start-vaelii-dev.sh`
turns on (`vaelii.browser.web/dev-repl`).  Before each request it reloads every watched
source file that changed since the last request, together with every loaded namespace
that requires one of them, transitively, in dependency order.

**A protocol, record, type or interface is never redefined.**  Re-evaluating a
`defprotocol` defines a new interface and empties the protocol's extension map, and
re-evaluating a `defrecord`, `deftype` or `definterface` defines a new class, so a KB
loaded before the reload would hold values the reloaded code no longer recognizes.  A
reload therefore loads a file form by form and leaves out each of those forms whose
protocol or class already exists; every other form is evaluated.  A record keeps its
methods inline, where protocol dispatch is a direct interface call, and a method that
calls a function reaches the reloaded function through its var.  An edit inside such a
form is not loaded: `restart-owed` names it until the process restarts, and the page
shows that list.  A form for a class that does not exist yet is evaluated.

**A held namespace is never re-evaluated at all.**  A namespace whose ns symbol carries
`:clojure.tools.namespace.repl/load false` holds protocols and method-less records
(`vaelii.impl.types.*`, `vaelii.impl.protocols`, …).  An edit to one reloads nothing on
its account, and `restart-owed` names it.

**Form by form, not tools.namespace's `refresh`.**  `refresh` removes each namespace with
`remove-ns` before it loads the file again, which re-evaluates every `defonce` in it and
empties the state a loaded KB keeps there: the cache registry, the change feed's
listeners, the thaw guard's installed readers.  Loading into the existing namespace
keeps a `defonce`'s value, as `require :reload` does.

**Only loaded namespaces reload.**  A dependent this process never loaded, such as an
LLM provider the browser has not reached, stays unloaded: loading it would run code the
running server does not use.

tools.namespace ships in the `:dev` profile only, so its dependency graph and ns-form
reader are resolved when `wrap-reload` builds the reloader, never at this namespace's
load.  The standalone jar compiles this namespace and has no tools.namespace.
raw docstring

affectedclj

(affected entries changed)

The namespaces an edit to the namespaces changed reloads, in the order to reload them: each changed namespace that is not held, and every namespace under entries that requires one of those, transitively, minus the held ones. An edited held namespace contributes nothing. Loaded or not is the caller's filter (reload!).

The namespaces an edit to the namespaces `changed` reloads, in the order to reload
them: each changed namespace that is not held, and every namespace under `entries` that
requires one of those, transitively, minus the held ones.  An edited held namespace
contributes nothing.  Loaded or not is the caller's filter (`reload!`).
sourceraw docstring

held-decl?clj

(held-decl? decl)

Is the ns form decl a held namespace's? The key is read off the ns symbol's metadata, the (ns ^{…} name) spelling every held namespace uses.

Is the ns form `decl` a held namespace's?  The key is read off the ns symbol's
metadata, the `(ns ^{…} name)` spelling every held namespace uses.
sourceraw docstring

reload!clj

(reload! nss)

Reload each of nss that this process has loaded, in order, leaving every existing protocol, record, type and interface as it was loaded. Returns {ns #{Name}} for the definitions each reload left out.

Reload each of `nss` that this process has loaded, in order, leaving every existing
protocol, record, type and interface as it was loaded.  Returns `{ns #{Name}}` for the
definitions each reload left out.
sourceraw docstring

restart-owedclj

(restart-owed)

The held namespaces, and the protocols, records, types and interfaces as ns/Name, edited on disk since this process started. The running process still runs the definitions it loaded, so these edits take a restart.

The held namespaces, and the protocols, records, types and interfaces as `ns/Name`,
edited on disk since this process started.  The running process still runs the
definitions it loaded, so these edits take a restart.
sourceraw docstring

scanclj

(scan dirs)

The source files under dirs as {file entry}, each entry {:ns :deps :held? :classes :time}.

The source files under `dirs` as `{file entry}`, each entry
`{:ns :deps :held? :classes :time}`.
sourceraw docstring

wrap-reloadclj

(wrap-reload handler {:keys [dirs]})

Ring middleware that reloads the changed sources under :dirs before each request (see the namespace docstring). Throws when tools.namespace is not on the classpath, which is what vaelii.browser.web/hot-reloading catches to serve without reloading.

Ring middleware that reloads the changed sources under `:dirs` before each request
(see the namespace docstring).  Throws when tools.namespace is not on the classpath,
which is what `vaelii.browser.web/hot-reloading` catches to serve without reloading.
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