I have built a Dynamic feature module sample with Fragments, sub components and dependent components based on plaid app, if you wish to check out here is the link. Now, i'm trying to convert it to Dagger Hilt using the official android document.
In core module which is the library module, app module and dynamic feature modules depend on
@Singleton
@Component(modules = [CoreModule::class])
interface CoreComponent {
/*
Provision methods to provide dependencies below to components that depends on
CoreComponent
*/
fun coreDependency(): CoreDependency
fun coreCameraDependency(): CoreCameraDependency
fun corePhotoDependency(): CorePhotoDependency
fun coreActivityDependency(): CoreActivityDependency
@Component.Factory
interface Factory {
fun create(@BindsInstance application: Application): CoreComponent
}
}
and it's module
@Module(includes = [CoreProvideModule::class])
abstract class CoreModule {
@Binds
abstract fun bindContext(application: Application): Context
}
@Module
object CoreProvideModule {
@Singleton
@Provides
fun provideCoreDependency(application: Application) = CoreDependency(application)
@ActivityScope
@Provides
fun provideCoreActivityDependency(context: Context) = CoreActivityDependency(context)
@Provides
fun provideCoreCameraDependency(): CoreCameraDependency = CoreCameraDependency()
@Provides
fun provideCorePhotoDependency(): CorePhotoDependency = CorePhotoDependency()
}
How is CoreComponent migrated? Do provision methods still stay and i only change
@Singleton
@DefineComponent
or
@Singleton
@DefineComponent(parent = ApplicationComponent.class)
for CoreModule i guess i only change
@EntryPoint
@InstallIn(CoreComponent::class)
or is this for adding provision methods in CoreComponent?
How do i create sub-component in app module?
If anyone has a sample with dynamic feature fragments and hilt, or tutorial to build, it would be more than welcome. I'm just working on it at the moment, if i figure it out i would post an answer