I am using Android compose and view model and I have a ViewModel that is scoped to a single Composable function which is a bottom sheet view, which is inflated using BottomSheetScaffold and I inject the ViewModel inside the Composable function using viewModel but I have a problem that viewModel function returns the same viewModel instance created before when I open the bottom sheet again.
In other words how to scope the ViewModel to a Dialog Composable function which is not related to NavHost and backStack
@Composable
fun ComposableExample(
) {
val viewModel: ExampleViewModel= viewModel() // createdOnlyOnce and always returns old instance
}