val stateHolder by remember { mutableStateOf(MyState()) }
Checking nowinandroid sample, they use a NiaAppState that they declare using the first way, without mutableStateOf. Supposedly, mutableStateOf is necessary to listen to changes in variables, so, why not using it?
Pablo
03/06/2025, 7:05 PM
For example, in this case, which approach is necessary and why?
Copy code
@Stable
class MyState{
var currentStep by mutableStateOf(Step.ARE_YOU_SATISFIED)
private set
fun updateCurrentStep(value: Step) {
currentStep = value
}
}
Pablo
03/06/2025, 7:06 PM
maybe it's because currentStep is already a mutableStateOf? and the value of MyState is not changed but the value of it's internal variable does?