I'm missing dagger modules in kotlin-inject. In th...
# kotlin-inject
p
I'm missing dagger modules in kotlin-inject. In theory it might work to create fake components as interfaces and let your root component implement it, but that causes issues because interfaces can only have public members. And most of the times in a gradle module I module internal dependencies that are used to create an object
e
This has come up before, have a couple of thoughts on it: The reason modules don't exist is because it simplifies the mental modal of things. You can use exiting kotlin idioms of composition and inheritance instead of having to lean a whole new thing about composing modules. I've also found it very hard in dagger to understand the graph when you have components depending on modules which in turn provide their own components. So the recommend way to split things up is either with inheritance:
Copy code
interface Feature1Component {
   ...
}

@Component
abstract class AppComponent : Feature1Component {
   ...
}
or by composition
Copy code
@Component
abstract class Feature1Component {
   ...
}

@Component
abstract class AppComponent(@Component val feature1: Feature1Component = Freature1Component::class.create()) {
   ...
}
If you are worried about those extra members on your component being visible to downstream code you can always hide it behind an interface
Copy code
interface AppComponent {
   val app: App
}

@Component
abstract class AppComponentImpl : AppComponent, Feature1Component
though I don't think it ends up being a big deal in practice.
And most of the times in a gradle module I module internal dependencies that are used to create an object
On the other hand this is something I'd like to improve on. The way the code generation works right now your dependencies end up having to be publicly visible in most cases. I do want to relax this.