title: Koin 3.2/Compose - injecting an activity-scoped viewmodel from a composable
body: <p>I have scoped a viewmodel to an activity like this:</p>
  <pre><code>    scope&lt;MyActivity&gt; {
        scoped&lt;UseCase1&gt; { UseCase1Impl(get()) }
        scoped&lt;UseCase2&gt; { UseCase2Impl(get()) }
        viewModel { parameters -&gt; MyViewModel(parameters.get(), get(), get()) }
      }
  </code></pre>
  <p>In my activity I cannot access the viewmodel inside a composable with this call:</p>
  <pre><code>        setContent {
  
        val viewModel: MyViewModel by org.koin.androidx.compose.viewModel {
          ParametersHolder(mutableListOf(&quot;1&quot;))
        }
        viewModel.doSomething() 
  }
  </code></pre>
  <p>UNLESS I also do this outside the composable:</p>
  <pre><code>   private val viewModel by viewModel&lt;CameraNameViewModel&gt; { parametersOf(&quot;1&quot;) }
  
    override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      viewModel // If I comment this, it crashes
  
     // setContent etc
  }
  </code></pre>
  <p>The error is</p>
  <pre><code> Caused by: org.koin.core.error.NoBeanDefFoundException: |- No definition found for class:'com.anonymised.path.to.MyViewModel'. Check your definitions!
  </code></pre>
  <p>Deep-diving with the debugger, it looks like the activities mViewmodelStore property is only populated when accessed outside the composable. I do have a workaround in that I can just inject every viewmodel in my top-level activity, but it doesn't seem right basically injecting it twice.</p>