How sapjs works

When anything on the page changes, sapjs runs one pass over the app.

1IntakeRead every field (state=, bind, items=) into fresh objects. A state= attribute declares a field on an element.
2ComputeRun the calc: fields in dependency order.
3PaintUpdate text, show, attr: and class:. Write only what changed.
4DiscardThrow the objects away; the next pass rebuilds them, reading every saved field from the page.

Each pass rebuilds the app's data from the page, so no copy of the saved data in JavaScript can drift from it.

A paint writes only when the new value differs from the old one. A saved file already holds its painted values, so loading it changes nothing. The console reports that as mount writes 0.

React keeps its state in JavaScript and draws the DOM from it. In a file that saves itself, the DOM is what gets saved, and live sync rewrites it from outside. sapjs reads its state from there every time.

Read how sapjs works in depth

sapjs by David Miranda. MIT-0 license.