The second issue is constructor lazy & provide...
# koin-contributors
k
The second issue is constructor lazy & provider injection into constructor. It’s bad to have required dependencies of a component into properties because DI library can’t do that
I have written
Proxy<T>
and
Lazy<T>
wrappers that resolve dependencies lazy and it will be good to have it build in the library
a
Can you give a example?
k
Copy code
class Artifact(
   lazyDep: Lazy<Dep1>
   proxyDep: Proxy<Dep2>
)
Copy code
module {
    single {
         Artifact(lazyDep = lazy<Dep1>(), proxyDep = proxy<Dep2>())
    }
}
It allows injection in a constructor without resolve dependencies immediately
a
yes I see
can't we use
inject()
here? 🤔
k
Very important to have static analyzer rule to check confusing between
get
and
lazy
,
provider
In my own implementation
Copy code
module {
    single {
         Artifact(lazyDep = get<Dep1>(), proxyDep = get<Dep2>())
    }
}
But will be never successfully resolved
can’t we use
inject()
here? 🤔
Do you mean property injection ?
a
no I mean, we have
get
to resolve directly
... I don't have the Koin codebase under the hand 😛
k
no I mean, we have
get
to resolve directly
But it resolve all dependencies in a constructor when I’ll get
Artifact
. But I want to resolve them lazy
a
sure I see