Tag: ViewModel
All the articles with the tag "ViewModel".
-
Android LiveData — Observable, Lifecycle-Aware, and the Two-Variable Pattern
Understand LiveData's two core properties — observable data holder and lifecycle-aware delivery — the difference between setValue and postValue, and why ViewModel uses a private MutableLiveData with a public LiveData to enforce MVVM boundaries.
-
Android ViewModel Internals — ViewModelProvider, ActivityThread, and the Factory Pattern
Understand the full internal chain of Android's ViewModel — how ViewModelProvider, ComponentActivity, NonConfigurationInstance, ViewModelStore, and ActivityThread work together across three lifecycle scenarios, and when a ViewModelFactory is required.
-
Android ViewModel Internals — Why Data Gets Lost on Rotation and How to Fix It
Build a ViewModel from scratch to understand why Android data is lost on orientation change, how storing it in the Application class fixes one problem but introduces another, and the two rules every ViewModel must follow.