Specialized ViewModels & Coordinators¶
When To Use It¶
These primitives are not alternate container shapes. They solve specific workflow problems that show up repeatedly across apps:
FormVMfor snapshot/revert/approve edit flowsDiscriminatorVMfor active-mode or active-pane coordinationNotificationVMandConfirmationVMfor render-side notification stateModalVMfor VM-backed modal completion
Use them when the workflow itself is the reusable primitive. If the need is just "a leaf with one more property", stay on the core hierarchy and compose the smaller helpers instead.
Shape And Ownership¶
These types typically wrap or coordinate other VM state rather than replacing the core ownership hierarchy:
FormVMowns edit snapshots and approval/revert flow around a target VMDiscriminatorVMowns active-case switchingNotificationVMandConfirmationVMown render-ready notification stateModalVMowns completion state around a presented modal workflow
Lifecycle And Messaging¶
Specialized primitives matter when a recurring workflow has its own lifecycle or message flow:
- forms track dirty/valid/approve/revert transitions
- discriminators switch active cases while keeping case selection observable
- notification and confirmation VMs mirror host notification streams
- modal VMs bridge VM state with dialog completion
The dedicated pages cover the exact hooks and host seams each workflow uses.
Cross-Language Surface¶
All four flavors ship the same conceptual set of specialized primitives, with idiomatic naming differences only. The dedicated pages call out where example apps currently exercise them and where a flavor surfaces helper APIs idiomatically.
Example¶
In the Notes Workspace examples, the editor flow composes FormVM with
DiscriminatorVM, while notifications and dialogs use the render-oriented
primitives instead of growing ad hoc state on unrelated container VMs.
The flagship examples are especially useful here:
- the editor pane composes
FormVMandDiscriminatorVM - the notifications pane projects
INotificationHub.PendingintoNotificationVMinstances - the dialog adapters show where
ModalVMfits whenIDialogService.Presentis the right host seam
The dedicated pages below call out the relevant example files directly.
Common Pitfalls¶
- Reaching for a specialized primitive when a plain
ComponentVMplus a command or property would do. - Treating these pages as alternatives to the core container families.
- Assuming every example app must use every specialized primitive directly.