So I want to use mutableStateOf in my ViewModel like this:
Copy code
private var _state: State by mutableStateOf(Loading)
override val state: State = _state
fun onLoadClicked() {
_state = Loading
viewModelScope.launch {
_state = when (val content: Content? = loadData()) {
null -> Error
else -> PresentData(content)
}
}
}
So now I would like to test the behaviour of onLoadClicked. But I do not know how to verify that calling that function sets the state to Loading and than to PresentData/Error. I could observe a liveData and remember all states is was set to but how do I do it with mutableStateOf?