Consider the following injector:
class Injector constructor(secretSauce: SecretSauce) {
val kodein = Kodein {
bind<SpicyBeans>() with factory { beans: List<Bean>, herbs: List<Herb> ->
SpicyBeans(secretSauce, beans, herbs)
}
}
}
And the following business logic:
class TastyMeal {
private lateinit var injector : Kodein
private lateinit var spicyBeans : SpicyBeans
fun initialiseWithInjector(kodein : Kodein) {
injector = kodein
val herbs = listOf(Coriander(), Cumin())
val beans = listOf(Pinto(), BlackEyed())
// fetch SpicyBeans via given Kodein Factory, given herbs and beans here
}
}
How can I use Kodein's direct injection feature to fetch a SpicyBeans
instance using a factory, passing in List<Herb>
and List<Bean>
after TastyMeal
is instantiated? I can't find an example in the documentation.