Nesting, identity and lazy rendering
A live component can contain an independent child component. A parent update keeps the child's DOM and state, and a child action uses the signed ancestor state to reconstruct the context it was rendered in. Changing the child's ID mounts a new instance. To update a mounted child from the parent, send it an event.
- For a list of components that can reorder or change membership, pass each one a unique ID such as
<row-editor live-id="editor-{$row.id}" record="{$row}" />. For an explicit<live>block, set itsidattribute. - Use
live-key="{$item.id}"for repeated siblings whose DOM identity should survive a reorder. - Use
live-ignorefor a browser-owned widget. Keep KScript's bound controls and action handlers outside that widget. - Use
live-replaceto build a fresh node on each redraw. - Add
lazyto initialize and render the block when it enters the viewport, ordeferto load just after the document is ready. The optional direct<placeholder>child is rendered before the block mounts.
<live id="summary" lazy>
<placeholder><p role="status">Loading summary…</p></placeholder>
<state name="shown" value="true" />
<p @if($shown)>Ready</p>
</live>