title: android ViewModelFactory with hilt
body: <p>I am first trying android <code>ViewModel</code> and <code>Hilt</code> DI</p>
  <p>As i understand from below link, to initialize ViewModel with a value on run-time i should use <code>ViewModelFactory</code></p>
  <p><a href="https://codelabs.developers.google.com/codelabs/kotlin-android-training-view-model/#7" rel="noreferrer">Use a ViewModelFactory</a></p>
  <pre><code>//ViewModel
  class ScoreViewModel(finalScore: Int) : ViewModel() {
     // The final score
     var score = finalScore
     init {
         Log.i(&quot;ScoreViewModel&quot;, &quot;Final score is $finalScore&quot;)
     }
  }
  
  //ViewModelFactory
  override fun &lt;T : ViewModel?&gt; create(modelClass: Class&lt;T&gt;): T {
     if (modelClass.isAssignableFrom(ScoreViewModel::class.java)) {
         return ScoreViewModel(finalScore) as T
     }
     throw IllegalArgumentException(&quot;Unknown ViewModel class&quot;)
  }
  
  
  //Fragment
  viewModelFactory = ScoreViewModelFactory(ScoreFragmentArgs.fromBundle(arguments!!).score)
  </code></pre>
  <p>And to use ViewModel with hilt i should use <code>@ViewModelInject</code> as explained in below link</p>
  <p><a href="https://developer.android.com/training/dependency-injection/hilt-jetpack" rel="noreferrer">Hilt and Jetpack integrations</a></p>
  <pre><code>//ViewModel
  class ExampleViewModel @ViewModelInject constructor(
    private val repository: ExampleRepository,
    @Assisted private val savedStateHandle: SavedStateHandle
  ) : ViewModel() {
    ...
  }
  
  //Activity / Fragment
  @AndroidEntryPoint
  class ExampleActivity : AppCompatActivity() {
    private val exampleViewModel: ExampleViewModel by viewModels()
    ...
  }
  </code></pre>
  <p>But how to use <code>Hilt</code> with <code>ViewModelFactory</code>?</p>
  <p>It seems the answer is in the <code>@Assisted</code> but i can't figure out how</p>
  <p>How to tell hilt i like it to inject repository interfaces to ViewModel while still allowing ViewModelFactory to initialize the ViewModel with parameters on run-time?</p>