Jetpack Compose and MVI: Are mutable UI classes always bad?

138 Views Asked by At

Are there any valid reasons to make a UI data class property mutable?

For example: I have an app that allows users to send messages with polls with multiple choices using Checkboxes. I want ViewModel to maintain state of checkbox through both recompositions and activity destruction (due to device rotation). If I'm developing with Jetpack Compose, rememberSaveable does not preserve state through activity destruction (at least on my android phones), but ViewModel will.

My current solution introduced a mutable property in the data class for the checkbox element that would 'remember' whether the box was checked. Since objects of checkbox class were held in VM, they survived orientation changes.

0

There are 0 best solutions below