title: Why does android "by viewModels()" take a lambda with a factory, not with a viewmodel?
body: <p>The lambda parameter in viewModels() method is a factory itself, so why google requires us to create a factory for the factory? Is it just an api fault or an intended decision?</p>
  <p>I made a wrapper, which allows to pass parameters to the ViewModel much easier without creating a special factory. Are there any drawbacks of this solution?</p>
  <pre class="lang-kotlin prettyprint-override"><code>class UserActivity {
      val user by lazy { intent.getSerializableExtra(&quot;user&quot;) as User }
      val viewModel by easyViewModels { UserViewModel(user) }
  
      inline fun &lt;reified T : ViewModel&gt; easyViewModels(noinline factory: () -&gt; T) = viewModels&lt;T&gt; {
          object : ViewModelProvider.Factory {
              override fun &lt;S : ViewModel?&gt; create(modelClass: Class&lt;S&gt;) = factory() as S
          }
      }
  }
  </code></pre>
  <p>The reason for that is that I'm trying to integrate Dagger with Jetpack ViewModels. There is an another solution with multi binding: <a href="https://stackoverflow.com/questions/54347924/inject-property-into-viewmodel-using-dagger-2/54353028#54353028">Inject property into ViewModel using Dagger 2</a>, but it doesn't work with the assisted injection feature. So I made it the following way:</p>
  <pre class="lang-kotlin prettyprint-override"><code>class UserActivity : AppCompatActivity() {
      @Inject
      lateinit var userViewModelFactory: UserViewModel.Factory
  
      val user by lazy { intent.getSerializableExtra(&quot;user&quot;) as User }
      val viewModel by easyViewModels { userViewModelFactory.create(user) }
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_user)
          DaggerAppComponent.create().inject(this)
      }
  }
  </code></pre>
  <pre class="lang-kotlin prettyprint-override"><code>class UserViewModel @AssistedInject constructor(
      val userUsecase: UserUsecase,
      @Assisted val user: User
  ) : ViewModel() {
  
      @AssistedFactory
      interface Factory {
          fun create(user: User): UserViewModel
      }
  }
  </code></pre>
  <p>Is it correct?</p>