title: Android Compose MVVM - How to reference a viewModel object in a Composable function that doesn't take arguments?
body: <p>How would the <code>@Composable ContentFeed()</code> function access the <code>viewModel</code> which was created in the Activity? Dependency injection? Or is that a wrong way of doing things here? The <code>viewModel</code> should always have only have one instance.</p>
  <pre class="lang-kotlin prettyprint-override"><code>// MainActivity.kt
  class MainActivity : ComponentActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          val viewModel by viewModels&lt;MainViewModel&gt;()
          setContent {
          PracticeTheme {
              // A surface container using the 'background' color from the theme
              Surface(color = MaterialTheme.colors.background) {
                  PulseApp(viewModel)
              }
          }
      }
  }
  
  // TabItem.kt
  typealias ComposableFun = @Composable () -&gt; Unit
  
  sealed class TabItem(var icon: Int, var title: String, var content: ComposableFun) {
      object Feed : TabItem(R.drawable.ic_baseline_view_list_24, &quot;Feed&quot;, { ContentFeed() })
  }
  
  // Content.kt
  @Composable
  fun ContentFeed() {
      // I need viewModel created in MainActivity.kt here
  }
  </code></pre>