reactormonk
07/08/2025, 4:08 PMget()
, but then the injected code reuses the implementation. Can I somehow forward the injection to the actual call site, so an object is being created on each invocation?Sergey Dmitriev
07/09/2025, 8:32 AMclass YourClass(
provider: () -> YourDependency
) {
fun foo() {
val newInstance = provider()
}
}
// Koin
factory {
YourDependency()
}
factory {
YourClass(
provider = { get() }
)
}
reactormonk
07/09/2025, 8:33 AM() -> A
and () -> B
factoriesSergey Dmitriev
07/09/2025, 8:35 AMfun interface ProviderA : () -> A
fun interface ProviderB : () -> B
To help it with types?reactormonk
07/09/2025, 8:35 AMSergey Dmitriev
07/09/2025, 8:37 AMfactory {
YourClass(
provider = { get<YourDependency>() }
)
}