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

abbic

02/22/2023, 1:35 PM
is it right that calling inject inside a Composable that isnt inside a class that implements KoinComponent means i have to pass a class parameter, like so?
Copy code
val router by inject<RouterViewModel>(RouterViewModel::class.java)
ah i see, because KoinComponent's methods are inlined and KoinJavaComponent's arent
@Pedro Alberto i think this ^ is the reason
theres a way to inject directly, without
KoinComponent
, by using the methods on
KoinJavaComponent
. but its methods arent inlined so you need to pass the class parameter
p

Pedro Alberto

02/22/2023, 3:02 PM
am not sure why but maybe has to do with reflection stuff not sure.
but does it work with KoinComponent ?
a

abbic

02/22/2023, 3:02 PM
yeah. i think the answer is that i simply have to swallow my pride and use the less nice looking function
yeah its fine with
KoinComponent
, tried it in another context
p

Pedro Alberto

02/22/2023, 3:04 PM
and you still need to use your way or this way works ?
val router by inject<RouterViewModel>()
cus I expect that with KoinComponent you don't have to use RouterViewModel::class.java
a

abbic

02/22/2023, 3:04 PM
thats right
p

Pedro Alberto

02/22/2023, 3:05 PM
nice 🙂
a

abbic

02/22/2023, 4:29 PM
KoinJavaComponent looks simple, feels like i could implement these functions for myself locally and inline them