Skip to content

DynamicModule ​

<DynamicModule> -- a reactive document, after Bret Victor's [Tangle](http://worrydream.com/Tangle/): prose whose numbers you can grab, and whose other numbers follow.

It is the scope, not a control panel. The controls live inline where they are read — a <Knob> you drag, a <Toggler> you click — and each contributes its name as a wildcard. Everything else in the subtree that is an Epsil expression over those wildcards is a template, re-evaluated on every move: a <Dynamic> readout, a <PaneSelector> selector, or an attribute of any other component, so the same knob can drive a sentence and the plot beside it.

``html <DynamicModule> A <Knob name="n" value="4" min="1" max="8" step="1" />-element set has <Dynamic value="2^_n" /> subsets<PaneSelector selector="_n > 5"><span data-pane="True">, which is already more than you want to list</span></PaneSelector>. <Figure kind="subset" value="[1,3]" n="_n" /> </DynamicModule> ``

Unlike <Manipulate> — the same substitution machinery behind a Wolfram-style panel of sliders — a dynamic module has no chrome of its own and renders nothing. Nested modules are separate scopes: a control belongs to its nearest enclosing one.

A dynamic module is not required: the page itself is a scope, and a control and a readout with no wrapper at all still find each other. The wrapper is for isolation -- two examples on one page that both call their knob n.

A SECOND, unrelated capability lives here too: a transcript. When a <Cell> inside a module asks (transcriptFor), the module lazily creates one shared compute-engine scope and history (@enumeratio/frontend's Transcript) and hands it back to every cell that asks -- so Cell(a := 5) then Cell(a^2) share a binding and Out(n) / % read each other back, Wolfram's $Line transcript. This is Notebook's rendering (Notebook(cells) is DynamicModule([Cell(...), ...]) under a Wolfram name, symbols.ts), and it is independent of the _k hole-filling Scope above: a module with no cells in it never creates one.

Demos·packages/components/src/dynamic-module-box.ts· draws DynamicModule, Notebook

Props

PropTypeDefaultNotes
tracebooleanfalseAnnounce every knob move on the console under the scope debug namespace.
trackedSymbols
attribute tracked-symbols
string""All / a comma list of symbol names -- symbols.ts's TrackedSymbols lowering. Absent (the default) keeps this a plain transcript: cells evaluate top to bottom, Out/In/InString/% stay live, and cell-number references are allowed.
evaluatorstring""Evaluator -> "Local" | "Worker" -- see notatio-out.ts's TranscriptHost.
workerSetup
attribute worker-setup
string""Module URL whose configure(ce) declares the page's libraries into the session's engine -- overrides the host-wide __notatioWorkerSetup gate for this one module (a test, or a page with more than one library set).
timeConstraint
attribute time-constraint
number0TimeConstraint, in SECONDS -- Wolfram's own option name and unit (VerificationTest's TimeConstraint is seconds too, unlike evaluation's own internal timeMs): tried cooperatively first, then hard-kills and restarts the session (https://github.com/enumeratio/enumeratio/wiki/Computation §5.2–5.3). Unset (the default, 0) means no deadline at all -- a Worker evaluator without one can still be interrupted by the "stop" control, just never automatically.

As a web component

Plain custom elements, no framework required: import @enumeratio/frontend for the side effect and write <dynamic-module-box> in any HTML. Attributes are kebab-case and always strings; the props table above names each one's attribute where it differs from its prop.