Skip to content

docs: add the Compositions guide (nesting, props, lifecycle)#83

Merged
joaomdsg merged 1 commit into
mainfrom
docs/compositions
Jun 1, 2026
Merged

docs: add the Compositions guide (nesting, props, lifecycle)#83
joaomdsg merged 1 commit into
mainfrom
docs/compositions

Conversation

@joaomdsg

@joaomdsg joaomdsg commented Jun 1, 2026

Copy link
Copy Markdown
Member

What

Adds a dedicated Compositions guide — the concept other frameworks call "components," documented under Via's own vocabulary. Closes the long-standing gap where the composition model was scattered across Getting started, the glossary, and Actions & lifecycle with no page of its own.

Contents

  • Nesting — a child is an exported struct field whose pointer has View; Mount folds its state in by reflection, with automatic per-instance isolation via field-prefixed wire keys (A.count, B.count).
  • One tree, one render — the tree is allocated once per tab; the framework drives only the root; children are orchestrated by the parent; whole-tree top-down re-render + morph.
  • Passing props — the blessed model: props are View parameters (compiler-checked, reactive by re-render). Event handlers are props too.
  • Per-instance initial state — seed in the parent's OnInit via .Write(ctx, …), with a verified caveat: never reassign a child by value (binding is by-address before OnInit, so a struct-literal reassign zeroes slot/key — the value paints once but client bindings go dead and updates mis-route).
  • Events (child → parent) — forward through a root action method, since actions dispatch by root method name.

Nav / supporting edits

  • New page at Guides → nav_order 2 (after Actions & lifecycle); bumps Rendering/Routing/File uploads/Plugins by one.
  • Glossary Composition entry now links to the page.

Docs-only; go build ./... green.

Add a dedicated Guides page for the composition model — the concept
other frameworks call "components." Covers nesting (child = struct
field, automatic per-instance state isolation), the single-tree render
model, prop passing via View parameters, per-instance state seeding in
OnInit (with the by-address binding caveat), and routing child events
up through root action methods.

Slot it in as Guides nav_order 2 (after Actions & lifecycle), bumping
Rendering/Routing/File uploads/Plugins; link the glossary Composition
entry to the page.
@joaomdsg
joaomdsg merged commit 68db937 into main Jun 1, 2026
6 checks passed
@joaomdsg
joaomdsg deleted the docs/compositions branch June 1, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant