Hi! Why can't Koin search for classes registered f...
# koin
m
Hi! Why can't Koin search for classes registered for DI that implement an interface that is required by some other component?
f
A wild guess would be that class inheritance is already a large thing on the JVM. That would require traversing the entire dependency tree (up to which point? Do you allow injecting
Object
or
Any
, which would be all your dependencies ?). That's a massive performance an dmemory cost, for very little usage. Just declare your modules with factory<InterfaceYouNeed> { ImplementingClass() }
m
Yeah, search upwards, but exclude generic classes in JDK (e.g. package filter, java.* etc) and up. And only in case an exact match is not found. And must only result in one match. Should possibly be an option in the module.
a
for a definition you can bind extra definition with
bind
or
binds
DSL keyword
and then you can request all instance of a given type with
getAll
here it’s mainly declarative to avoid reflection analysis
m
Oki, that is another use case.
Not my wish to avoid boilerplate. No problem for cake based DI I think.