Expose UI State as StateFlow
Publish a single source of truth for the screen.
One Source of Truth
Your screen needs a single, reliable picture of its data. A StateFlow gives you exactly that: one observable value the UI can trust.
Model the Screen as State
Bundle everything the screen shows into one immutable data class. Loading, data and errors all live together in a single object.
data class HomeState(
val isLoading: Boolean = false,
val name: String = ""
)All lessons in this course
- A Cross-Platform ViewModel Base
- Expose UI State as StateFlow
- Handle User Intents & Actions
- Bind the ViewModel to Each UI