Marco Pierucci
03/03/2024, 9:30 PMevant
03/03/2024, 11:01 PMMarco Pierucci
03/03/2024, 11:21 PMModule A
interface ApplicationComponent
( The implementation live on different sourcets but thats not important I believe
Module B
interface Repository
internal class RepositoryImpl(more internal deps): Repository
interface ModuleBComponent {
@Provides
fun provideRepo(impl:RepositoryImpl): Repository = iml
(This obcs does nto compile
}
The usual pattern I go with is :
AplicationComponent: ModuleBComponent
Ive tried a fiew works around with abstract classes bu eventually ModuleA generated code tries to reference the internal class so compilation is not possibleevant
03/03/2024, 11:41 PMinterface ModuleBComponent {
val repo: Repository
}
@Component
abstract class MyoduleBComponentImpl : ModuleBComponent {
@Provides
fun provideRepo(impl:RepositoryImpl): Repository = impl
}
...
@Component
abstract class ApplicationComponent(@Component val moduleB: ModuleBComponent)
with the downside is you'll need different scopes for the 2 components, which may or may not be fine depending on how circular your dependencies areMarco Pierucci
03/03/2024, 11:42 PMevant
03/03/2024, 11:43 PMMarco Pierucci
03/04/2024, 12:12 AM