Interview frequency: …
Short answer
MVVM usually relies on several independent state streams, while MVI imposes a single immutable state with a strict flow of intents and side effects.
Explanation
In traditional MVVM you may find isLoading, users, and errorMessage as separate StateFlows, which can sometimes cause inconsistent states. In MVI (Model-View-Intent) the screen is represented as one comprehensive state through a data class or sealed interface, and user wishes are received as intents, while individual quick events (such as navigation or showing a Snackbar) are expressed as single-event side effects.
Code example
// MVI State
data class ProfileState(
val isLoading: Boolean = false,
val profile: Profile? = null,
val error: String? = null
)
// MVI Intent
sealed interface ProfileIntent {
data object Load : ProfileIntent
data class UpdateBio(val newBio: String) : ProfileIntent
}Common mistakes
- Resending the same one-off event such as showing a Toast every time the UI is recomposed in MVI because it was not isolated from the state.