Andreas Sinz
12/11/2017, 10:08 AMclass Foo(val bar: Bar) {
fun start() { }
}
class Bar(val baz: Baz)
class Baz()
fun main(args: Array<String>) {
val kodein = Kodein {
bind<Foo>() with singleton { Foo(instance()) /* auto retrieve the instance of Bar*/ }
bind<Bar>() with factory { Bar(instance()) }
bind<Baz>() with factory { Baz() }
}
val foo: Foo = kodein.instance()
foo.start()
}
This way your classes do not need to know about Kodein
or KodeinInjector
and you are using Kodein to do DI instead of Service locating