Is this the way to do it? Using `Dagger2` I had it...
# kodein
j
Is this the way to do it? Using
Dagger2
I had it divided by modules and I see this like a dirty way to do the dependency injection, is there any other way to do it cleaner?
s
You can create modules by
val someModule = Kodein.Module("name") { ...  }
. This keeps stuff nicely organized
And you can ’import` your modules for your main Kodein object/component.
j
So, let's say I have a module for my list and my details, ok? So on
Dagger2
I had a module for each feature, and inside of it I put the things that I need, like
Repository
,
Usecase
, etc... so I can create a class as I did before like
ListModule
and then inside of it to the
val listModule = Kodein.Module("name"){..}
?
There's no
@Module
or something to say that class is a module, right?
s
No annotations. Just code.
You can put the `bind`ings inside the lambda of your `Kodein.Module`s. And then
import
(or `addImport`…..) them in your (main/top) Kodein object
r
You should definitely read the core documentation here https://kodein.org/Kodein-DI/?6.2/core
It's well written and easily understandable
Also there is a specific documentation for using kodein on Android here https://kodein.org/Kodein-DI/?6.2/android