title: View Model not destroyed on back press in jetpack compose
body: <p>I am aware there are many similar questions and I have gone through them, still my issue is not solved.</p>
  <p>Minified example of my problem,<br />
  I have 2 composables <code>ScreenA</code> and <code>ScreenB</code>.<br />
  Both composables have separate viewmodels.
  I am starting at screen A and navigating to screen B. On back button press, I expect the screen B view model to be destroyed. So when I navigate again to screen B, I want its viewmodel to be created again.</p>
  <p><strong>ScreenA</strong></p>
  <pre><code>@Composable
  fun ScreenA(
      screenViewModel: ScreenAViewModel = hiltViewModel(),
  ) { 
    // Compose code
  }
  </code></pre>
  <p><strong>ScreenB</strong></p>
  <pre><code>@Composable
  fun ScreenB(
      screenViewModel: ScreenBViewModel = hiltViewModel(),
  ) { 
    // Compose code
  }
  </code></pre>
  <p>From <a href="https://developer.android.com/jetpack/compose/libraries#hilt-navigation" rel="nofollow noreferrer">the Hilt and Jetpack Navigation Docs</a>, my understanding is using <code>hiltViewModel()</code> should scope the viewmodel to the particular composable. I am not clear if there is some mistake there.</p>
  <h3>How I have verified that the view model is not destroyed?</h3>
  <p>Added a breakpoint in screen B viewmodel init block. It is reaching init only once when I navigate back and forth.</p>
  <p><strong>Referred Questions</strong><br />
  <a href="https://stackoverflow.com/questions/68347794/how-to-destroy-a-viewmodel-when-user-leave-a-screen">How to destroy a ViewModel when user leave a screen</a><br />
  <a href="https://stackoverflow.com/questions/68857820/how-to-share-a-viewmodel-between-two-or-more-jetpack-composables-inside-a-compos/68857871#68857871">How to share a viewmodel between two or more Jetpack composables inside a Compose NavGraph?</a><br />
  <a href="https://stackoverflow.com/questions/68971231/activity-view-model-in-jetpack-compose">Activity view model in Jetpack compose</a><br />
  <a href="https://stackoverflow.com/questions/69064105/android-compose-navigation-and-viewmodel-lifecycle">Android Compose Navigation and ViewModel lifecycle</a><br />
  <a href="https://stackoverflow.com/questions/68691725/different-viewmodel-for-different-composable-functions-inside-same-activity">Different viewmodel for different composable functions inside same activity</a></p>
  <p>Sample repo with minimum reproducible code - <a href="https://github.com/Abhimanyu14/compose-navigation-sample" rel="nofollow noreferrer">https://github.com/Abhimanyu14/compose-navigation-sample</a></p>