- Select in A Screen
- navigate to B Screen
- edit the product info in B Screen
- push Save Button, when update success, navigate up to A Screen
- A Screen show update list
Screen
sealed class Screen (
val route: String
) {
object List: Screen("product_list") //-->A Screen
object EditProduct: Screen("edit_product") //-->B Screen
}
NavHost in MainActivity onCreate
NavHost(navController = navController, startDestination = Screen.Splash.route) {
composable(route = Screen.List.route) {
ListScreen()
}
composable(route = Screen.EditProduct.route) {
EditProductScreen()
}
A is a screen that brings up remote data and represents the list, and B contains detailed information about the product selected from A.
After entering the information about the product in B, I would like to update the list of A to show the revised information when I return to A by navigate up.
In this case, how should I deal with it?
LaunchedEffect(true) {
viewModel.eventFlow.collectLatest { event ->
when(event) {
is UiEvent.SaveTask -> {
//previousBackStackEntry?.savedStateHandle?.set<Boolean>("save_result", true)
onSave()
}
}
}
}
when I called onSave() --navcontroller::popBackStack, navigate to A Screen, but list isn't update
