2

I am following the official Android guide for Using Dagger in multi-module apps, and I am able to get everything to compile and "work".

The problem is that I have a viewpager in my dynamic feature module and I need to have a parent "scoped" viewmodel. The documentation shows this example of injecting a ViewModel

// You want Dagger to provide an instance of LoginViewModel from the Login graph
@Inject lateinit var loginViewModel: LoginViewModel

While generally I use something like

val loginViewModel: LoginViewModel by hiltNavGraphViewModels(R.id.parentFragment)

Does anyone know of a way to properly scope a shared viewmodel?

Nelson.b.austin
  • 3,080
  • 6
  • 37
  • 63

0 Answers0