Skip to main content

Module deps

Module deps 

Source
Expand description

The static dependency graph a fine-grained DOM update is compiled from.

Stage A repaints a component by clearing its mount and rebuilding the subtree — correct, and O(the whole view) for a change to one field. Stage B emits a PATCHER instead, and a patcher needs three facts known before the program runs:

  • every SITE in the view that can change, and which state fields it reads;
  • every ACTION, and which state fields it writes;
  • every DERIVED field, and what it is derived from.

Then a turn that writes draft updates exactly the sites that read draft.

★ THE READ SET IS CLOSED, which is the whole difficulty and the whole value. The names a site LITERALLY MENTIONS are usually not state:

  • {remaining} where remaining is derived reads whatever the derivation reads — nothing ever writes remaining itself, so a literal read set would never update it;
  • {t} inside {for each t in todos:} reads todos — t is a window onto state, not state, and no action writes it;
  • {doubled} after {let doubled be n * 2} reads n.

Every one of those failures is SILENT: the page simply stops updating, on exactly the constructs real pages are built from. So resolution happens here, once, and the answer a site carries is already in terms of the fields an action can write.

★ The write set is a static OVER-approximation on purpose. A write inside an If counts even when the branch does not run: repainting a site that did not change is a wasted patch, while missing one leaves a visitor looking at a stale page. The two errors are not comparable.

Structs§

ComponentDeps
The whole graph for one component.
SiteDeps
One addressable place in a view that can change, and what it depends on.

Enums§

DepError
Why a component has no dependency graph.
SiteKind
What kind of thing a site is — which decides what the patcher emits for it.

Functions§

block_prop_writes
The PROPS a block writes — every one a mistake, since a prop is the parent’s value. bound are the names the block’s own header binds (an action’s parameters, a trigger’s values), which shadow a prop of the same name. The same walk as block_writes, so a verb that writes state is a verb that writes a prop.
block_writes
The state fields one block of statements writes — the same walk component_deps uses for an action, exposed so a lowering can ask about a body it is about to emit.
component_deps
Build the dependency graph for one component.