Skip to content

6.2.4. Group Family

6.2.4.1. When To Use It

Use GroupVM<VM> for an ordered collection of peer children when the parent owns the children but does not own a selected child. Toolbars, capability rows, stacked panels, and other peer lists usually belong here.

Group Family Map

HTML · SVG · PNG

6.2.4.2. Shape And Ownership

GroupVM mirrors the list-management surface of CompositeVM without the selection slot:

  • ordered children
  • add, insert, remove, replace, clear, atomic move, batch update
  • collection-changed notifications
  • no Current
  • no select_component / deselect_component

The group itself is still a component and may be selected by its own parent. It implements the base VM Collection Contract, not its selectable extension.

Group membership uses the same exclusive ownership protocol as composites: attaching a child owned by another mutable container is one atomic transfer. See Composite Family for the transfer, rollback, and deferred-disposal rules (spec/07 §1.1, mirroring spec/06 §4.2).

6.2.4.3. Lifecycle And Messaging

Lifecycle orchestration matches CompositeVM:

  • construct waits for all children to reach Constructed
  • destruct waits for all children to reach Destructed
  • the default destruct and dispose order is unspecified (spec 02 §6). Only DestructOrder(ChildOrder.Reverse) is guaranteed: it walks the children last child first, so a child that depends on an earlier sibling is torn down before it (ADR-0161). Construct order does not change, and every child is still disposed before the group, unless the dispose is foreign (spec 02 §7)
  • AutoConstructOnAdd(true) constructs a child added after construct starts; construct then also waits for that child while it stays a member. A child removed during the walk does not roll the group back (ADR-0186)
  • BatchUpdate() suppresses per-mutation collection events and emits one reset
  • each local collection change is followed by one CollectionChangedMessage on the group's hub, and a batch that changes the collection sends one Reset (ADR-0142)

Rust background-child settling follows the shared container rule in ViewModel Families.

Group children are peers. Their inherited select command must stay disabled while the group is their parent.

6.2.4.4. Cross-Language Surface

Concept C# Python TypeScript Swift Rust
Type GroupVM<VM> GroupVM[VM] GroupVM<VM> GroupVM<VM> GroupVm<VM>
Builder entry GroupVM<VM>.Builder() GroupVMBuilder[VM]() GroupVM.builder<VM>() GroupVM<VM>.builder() GroupVm::<VM>::builder()
Children setter Children(...) children(...) children(...) children { ... } children(...)
Reverse teardown DestructOrder(ChildOrder.Reverse) destruct_order(ChildOrder.REVERSE) destructOrder("reverse") destructOrder(.reverse) destruct_order(ChildOrder::Reverse)

6.2.4.5. Example

Representative build shape:

  • C#: GroupVM<IComponentVM>.Builder().Name("actions").Services(hub, dispatcher).Children(() => new[] { save, delete }).Build()
  • Python: GroupVMBuilder[ComponentVM]().name("actions").services(hub, dispatcher).children(lambda: [save, delete]).build()
  • TypeScript: GroupVM.builder<ComponentVMBase>().name("actions").services(hub, dispatcher).children(() => [save, delete]).build()
  • Swift: try GroupVM<ComponentVMBase>.builder().name("actions").services(hub: hub, dispatcher: dispatcher).children { [save, delete] }.build()
  • Rust: GroupVm::<ComponentVm<_>>::builder().name("actions").services(hub, dispatcher).children(move || vec![save.clone(), delete.clone()]).build()?

Rust ships the same peer-container and builder concepts.

6.2.4.6. Common Pitfalls

  • Reaching for GroupVM when the UI has one meaningful active child. That is CompositeVM.
  • Assuming peer children become selectable because they inherit leaf commands. The group contract keeps those commands disabled.
  • Expecting a child to remain in its former parent after adding it here. VMx transfers mutable ownership rather than permitting two parent lists.
  • Forgetting that group batching affects collection events only, not any separate list or observable helper you compose beside it.