For example, I have this simple Composable function
@Composable
fun TextExample(model: SomeViewModel = viewModel()) {
TextButton(onClick = { model.onClick() }) {
Text(text = "Test")
}
}
The SomeViewModel:
class SomeViewModel : ViewModel() {
private val _text = mutableStateOf("Test")
val text: String
get() = _text.value
fun onClick() {
if (text.isEmpty()) {
// TODO: need to start some activity
} else {
_text.value = ""
}
}
}
I clicking this Button and then the model must to handle this click. In some cases I need to start another activity. What is right way to do this?