java-mvvm
Installation
SKILL.md
MVVM in Java with ViewModel + LiveData
Instructions
Use Jetpack ViewModel as the state holder and LiveData as the observable transport between ViewModel and Fragment/Activity. The view is dumb: it renders an immutable UI state and forwards events.
1. Immutable UI State
Model UI state as a single immutable record (Java 17). One state per screen — not one LiveData per field.
public record ArticleListUiState(
boolean loading,
List<Article> articles,
String errorMessage
) {
public static ArticleListUiState initial() {
return new ArticleListUiState(false, List.of(), null);
}