Skip to content

4. Core Concepts

4.1. One Spec, Five Source Flavors

VMx is defined once in spec/ and implemented idiomatically in C#, Python, TypeScript, Swift, and Rust. The conceptual model stays aligned even when naming changes by flavor.

4.2. Lifecycle-Aware ViewModels

Component-family VMs (component, composite, group, aggregate, and hierarchical VMs) follow the same construction state machine: Destructed, Constructing, Constructed, Destructing, and terminal Disposed. Construction, destruction, reconstruction, and disposal are part of the framework contract rather than host-app convention. Form, discriminator, modal, and notification VMs have disposal only and no construction states.

Disposal is framework-wide and idempotent: independent teardown paths may call it without consumer-side coordination. It is valid from any state and runs a synchronous depth-first cascade. The complete per-type behavior is in the Disposal Contract.

4.3. Message Hub And Dispatcher

Component-family VMs receive a message hub and dispatcher. The hub carries property, lifecycle and collection messages across the tree, while the dispatcher centralizes foreground and background scheduling for reactive work. CompositeVM and GroupVM send one CollectionChangedMessage for each local collection change (ADR-0142). A batch that changes the collection sends one Reset. A renderer can follow composite and group membership through the hub.

4.4. Parent-Child Ownership

Leaf ComponentVMs model a single node. CompositeVM, GroupVM, and AggregateVM1..6 define ownership and traversal rules for children. Parent references, depth-first lifecycle cascades, and current-selection semantics are part of the shared shape.

4.5. Shared VM Collections

Groups and composites implement one ordered observable collection capability. Selection is a separate extension implemented only by composites. The shared atomic move operation changes order without replacing, reconstructing, reparenting, or deselecting the child; see the VM Collection Contract.

4.6. Idiomatic Naming By Flavor

Each flavor names the same concepts in its own language idiom (ADR-0006). Message payload property names also follow the local idiom, with the documented Count channel exception for collection messages. Cross-Language Naming gives the casing and the spelling of each concept in each flavor.

4.7. Conformance Catalog

The spec catalog in spec/12-conformance.md defines library IDs plus THEME-00x scenario IDs. Every catalog-complete flavor carries every library ID in its own conformance suite, and repository tooling checks coverage before CI passes.

4.8. Framework Surface

Beyond the lifecycle, hub, ownership, and collection contracts above, every flavor exposes these parts under its own naming idiom:

  • Collection-change events on container VMs, in addition to property and lifecycle messages.
  • Forwarding decorators that wrap VMs for instrumentation.
  • A RelayCommand with reactive canExecute triggers and explicit imperative re-evaluation notifications.
  • The command decorators CompositeCommand, DecoratorCommand, and ConfirmationDecoratorCommand, and the modeled-CRUD helper ModeledCrudCommands.
  • Tree utilities (walk, find, walk_expanded) for introspection.
  • 22 opt-in capability micro-interfaces (ISelectable, IExpandable, IClosable, IFilterable, IPageable, …) that layer behavior onto VMs.
  • Helper state classes ExpandableState, SearchableState, and TreeSelection, which tracks one current node of a hierarchy. SearchableState can observe a source-change signal, so an unchanged term stays synchronized with collection or member invalidations.
  • DerivedProperty<T> for computed values over N sources.
  • FormVM<T> for snapshot, revert, and validation flows.
  • DiscriminatorVM for single-active-key coordination.
  • AsyncResourceVM<T> for cancellable latest-wins acquisition.
  • PagedComposition and TokenPagedComposition for finite and cursor paging.
  • An opt-in notification sub-package (INotificationHub), IDialogService, and an ILocalizer hook for i18n.
  • DelayedTask for one replaceable delayed action on an injected scheduler (spec 11 §6, ADR-0219), as described in Delayed Work By Flavor.
  • Null-object service variants: NullMessageHub, NullDispatcher, NullNotificationHub, NullLocalizer, and NullDialogService.

Framework Primitives explains when to reach for each family.