:children materialises eagerly; :call pushes a stack frameA component needs two distinct ways to compose with other components:
Conflating the two would force callers to express "always-on sub-component" as some weird "calls itself forever" pattern, or to wedge return values into structural children.
Two distinct primitives:
:children on a component definition declares the structural
set. :children {:slot/left (s/embed :sidebar) :slot/main (s/embed :panel)} instantiates both children eagerly at the
parent's own instantiation time. They live in :conv/instances
alongside the parent, addressed through :instance/children. They
do not appear on :conv/stack.:call is an effect: (s/call :child/picker {} :on-picked).
It pushes a new frame onto :conv/stack. The child's HTML
replaces the parent's; on :answer, the frame pops and the parent
resumes via the named key.:children can't take return values. That's the point. If you
need an answer, that's a :call site, not a child slot.:call-in-slot covers the hybrid case. Sometimes you want a
sequential exchange that doesn't take over the page — a confirm
modal inside a panel, an inline editor on one cell. :call-in-slot <slot> <embed> :on-answer temporarily swaps the child in a known
slot; the answer returns to the parent without popping the page.:set-keyed-children;
see keyed.clj. Same composition model — children alongside the
parent, addressed by slot + key — but with append/remove/outer
patch reconciliation instead of full re-render.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 |