Skip to main content

State, identity, and data updates

Preserve local choices while updating server-provided data.

Before you start: Edit a value and conditional content.

Root data is read-only to scripts. A session data update replaces that record while retaining compatible instances. Local state belongs to an instance and its stable identity. Host bindings synchronize host-owned state across surfaces; they are separate from root data.

Update data, keep state​

Save locally, then edit only the message in Data.json. The saved status remains.

<Column state="{saved:false}" class="p-4 gap-3">
<Text bind-text="data.message" />
<Button title="Save locally" on-press="set saved to true" />
<Text bind-text="saved ? 'Saved' : 'Not saved'" />
</Column>
Update data, keep state
editable
Browser preview
rReady to explore
Environment & events

Browser rendering of the shared document. Host services are bundled demo mocks. XML edits reset local state; data edits preserve compatible state.

Interact with the preview to inspect emitted events and mocked service calls.

Try it: Edit the XML instead: the playground explicitly replaces the document, so the saved status starts again.

Changing a key or removing an instance with if creates fresh state on reinsertion. Closing a session discards its state. Keep durable choices in app services. Reference: state, key, host APIs.