bodo
01/10/2023, 3:38 PMdependencies {
implementation("lib2-api")
}
this means every time i change something in “lib2-api” “lib1-impl” needs to be recompiled
Option B (maybe faster one):
“lib1-impl” has not dependency to “lib2-api”. instead we use dagger in the “app” module and glue it together like this:
@Module
object Lib1ImplModule {
@Provides
fun provideLib1Impl(lib2Api: Lib2Api): Lib1Impl {
return new Lib1Impl(
formatText = { text ->
lib2Api.formatText(text)
}
)
}
}
So the implementation of Lib1 has a constructor parameter for a function which returns this formatted text. And the dagger implementation forwards this text to lib2Api and returns the formatted text.
What do you think which approach will be better? Defining dependencies and losing build performance or decoupling as much as possible module dependencies and gain build performance.
General question:
Are there any drawbacks using functions as constructor parameters?Javier
01/10/2023, 6:59 PM