re-frame.fresco.substrate¶
Use this namespace to run a Fresco app on Fresco's own substrate adapter. It
provides the adapter you pass to rf/init! at boot, before anything mounts; with
it, a Fresco app depends on core and Fresco alone, instead of adding a Reagent or
UIx adapter just for its reactive container.
It ships in day8/re-frame2-fresco as an optional namespace: nothing else in
Fresco requires it, so a build that installs Reagent or UIx instead carries none of
it, and re-frame.fresco does not re-export it. It is ClojureScript only; the
namespace does not exist on the JVM.
(rf/init! substrate/adapter)
(defonce app-root (h/client-root))
(h/render! app-root [h/frame-root {:id :app/main} [app]]
(js/document.getElementById "app"))
Fresco renders through react-dom/client and interprets its own hiccup, so it
needs no renderer from an adapter. What the adapter supplies is the reactive half:
the container app-db lives in, and derived values that notify when it changes.
Reagent, reagent-slim and UIx adapters also work under a Fresco tree, because every React adapter writes the same frame context. An app that already installs one for its other views runs its Fresco views on it and needs no second adapter. Installation teaches the boot line, and Use UIx or reagent-slim lists the other adapters and their coordinates.
Adapter spec¶
adapter¶
- Kind: var (map)
- Signature:
- Description: The adapter map you pass to
rf/init!to install Fresco's own adapter as the substrate;(:kind (rf/current-adapter))reads:rf.adapter/fresco. Install it before the first frame exists.- Installation is explicit; there is no default adapter.
- Mounting a
frame-root, or making any frame, beforerf/init!throws:rf.error/no-adapter-installed; afterrf/destroy-adapter!it throws:rf.error/adapter-disposeduntilrf/init!installs an adapter again. - Its derived values notify watchers from the moment they are created, which a
live Fresco view needs. The headless
re-frame.substrate.plain-atomadapter's derived values register no watch, so a view under it paints once and never updates: that adapter suits an SSR render, not a live view. - It adds no dependency: Fresco already requires
react, and the rest of the adapter is in core.
- Example:
See also¶
re-frame.adapter.reagentandre-frame.adapter.uix— the other adapters, on the same contract.re-frame.fresco—client-root,render!and the frame heads.