viewmodel-architecture-governance

Installation
SKILL.md

ViewModel Architecture Governance

This skill centralizes all architectural mandates for ViewModels to ensure consistency, testability, and resource efficiency.

1. Passive Initialization Mandate

The ViewModel constructor and init block MUST remain passive. It is strictly forbidden to launch coroutines or start data collection during construction.

  • Imperative Actions (One-shot loads, manual triggers): Expose a dedicated function (e.g., onStart()) and trigger it from the UI.
  • Reactive Data Streams (Database observers, Config flows): Avoid manual collection in init. Use the Declarative State Pattern with the stateIn operator.

See Passive Initialization Mandate for code examples and testing benefits.

2. UI State Modeling (The Hybrid Pattern)

To ensure a robust interface, use the Hybrid Model: a data class for global coordination and a sealed interface for mutually exclusive content.

Installs
17
First Seen
Sep 16, 2026