https://kotlinlang.org logo
#koin
Title
# koin
a

Ankit Kumar

03/06/2024, 1:47 AM
Hlw Everyone, need a suggestion regarding lazy injection Is there any other way then below one, with below approach I always need to do
param.value
to access it
Copy code
internal class LoginViewModel(
    private val loginUserUseCase: Lazy<LoginUserUseCase>,
    private val dispatcherProvider: Lazy<DispatcherProvider>
)

LoginViewModel(inject(), inject())
CMIIW, but if we keep non-lazy normal variables and do
get()
, those are eagerly initialised?
p

Pedro Francisco de Sousa Neto

03/08/2024, 1:01 PM
a

Ankit Kumar

03/08/2024, 1:38 PM
@Pedro Francisco de Sousa Neto but while doing constructor injection we can't use delegate or can I? with field injection its fine
p

Pedro Francisco de Sousa Neto

03/08/2024, 1:48 PM
I don't think so. Do you've any idea @arnaud.giuliani?
a

arnaud.giuliani

03/08/2024, 6:47 PM
field won't be delegated by using
inject
in constructor. Delegate form of
by inject()
is for property
then you have to deal with
Lazy<>
and
.value
a

Ankit Kumar

03/09/2024, 2:48 AM
got it thanks everyone