Why Your ViewModel Is Technically Unstable — and Why Compose Doesn’t Mind

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

ViewModels in Jetpack Compose are technically unstable classes because they inject dependencies from other modules, which the Compose compiler cannot verify for stability across module boundaries. However, this doesn't cause recomposition issues because ViewModels are instantiated once at the top level and only their stable state objects are passed down to child composables. The Compose compiler determines stability based on member immutability and traceability, but this analysis only works within the module where the compiler plugin is declared. In multi-module architectures, classes receiving cross-module injections become unstable, making this a consideration for modularized Android projects.

3m read timeFrom droidcon.com
Post cover image

Sort: