Learn / Who changes state
Presentation state is not a fact
DOM geometry — element bounding boxes, scroll offsets, caret positions inside an input — changes on every pointer move or scroll frame. Putting DOM measurements into the Model fires a Message and full view pass on every pixel of movement for values no transition reads.
Use this test to decide where state belongs: is it replayed, stored, sent over the wire, or read by update to decide a Message?
- If yes, it is an application fact and belongs in the
Model. - If no, it is presentation and belongs in a DOM
BehaviororMount.
Examples from the Foldkit Plus widgets:
- Selection vs. selection box: A page builder's selected node id is a fact (Delete reads it, URLs encode it), so it lives in the
Model. The bounding rectangle drawn around that node is measured directly byMeasure(foldkit-primitives/dom) and written as CSS custom properties with zeroMessages. - Form draft vs. caret position: Unparsed text in a form field is a fact because submit validates it; the cursor offset inside that
<input>stays in the DOM. - Hovered row across panels: When hovering a layer row highlights a node on another canvas, route hover through a
Messageinto theModel. Callsettlebefore saving so stale hover state is cleared.
Next
- See what happens when a synced Message reads local state during replay: Events, folds and gates
- Trace a domain entity, query, and write to the screen: From declarations to the screen
- Look up any term in plain English: Glossary