I have the following case:
fun MyScreen(
onNavigateUp: () -> Unit,
modifier: Modifier = Modifier,
viewModel: MyViewModel = hiltViewModel()
) {
val uiState by viewModel.uiState.collectAsState()
Scaffold(
topBar = {
...
, actions = {
IconButton(
onClick = onNavigateUp
) {
Icon(
imageVector = Icons.Rounded.Done,
contentDescription = stringResource(id = ...)
)
}
})
},
)
I would like to do something like:
onClick = {viewModel.doSomething(),onNavigateUp}
So basically call a view model function and then navigate back.
But when I do that the IDE tells me that onNavigateUp
is unused.
Is there any good practice in jetpack compose on how to execute multiple functions/lambdas upon an event?
Example:
onClick = {
viewModel.doSomething()
onNavigateUp() // or onNavigateUp.invoke()
}