diff --git a/di/README.md b/di/README.md index f563972..97f8c54 100644 --- a/di/README.md +++ b/di/README.md @@ -132,7 +132,6 @@ class HomeFragment : Fragment(), HasSupportFragmentInjector { There is not much to do for ViewModels except for adding a constructor annotated with `@Inject`: ```kotlin -@FragmentScope class HomeViewModel @Inject constructor(/* inject properties here if you want */) : ViewModel() {} ``` diff --git a/di/src/main/java/io/stanwood/framework/arch/di/factory/ViewModelFactory.kt b/di/src/main/java/io/stanwood/framework/arch/di/factory/ViewModelFactory.kt index abb8484..88eeec1 100644 --- a/di/src/main/java/io/stanwood/framework/arch/di/factory/ViewModelFactory.kt +++ b/di/src/main/java/io/stanwood/framework/arch/di/factory/ViewModelFactory.kt @@ -23,11 +23,11 @@ package io.stanwood.framework.arch.di.factory import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider -import dagger.Lazy import javax.inject.Inject +import javax.inject.Provider class ViewModelFactory @Inject constructor( - private val viewModel: Lazy + private val viewModel: Provider ) : ViewModelProvider.Factory { @Suppress("UNCHECKED_CAST") override fun create(modelClass: Class): T = viewModel.get() as T