Hey all! I see Koin supports `FragmentFactory` but...
# koin-contributors
m
Hey all! I see Koin supports
FragmentFactory
but I don’t find a way to inject the Koin’s
ViewModelProvider.Factory
. The whole point of using
FragmentFactory
is to be able to do constructor injection. Is there any way to inject the
ViewModelProvider.Factory
in a
Fragment
constructor using Koin?
Otherwise, we could consider add an API for that. 🤔
a
did you check
org.koin.androidx.fragment
sources, in
koin-android
?
there is the
KoinFragmentFactory
m
Hm, I might not have expressed myself well. Let me rephrase: what I meant is that we need to inject the
ViewModelProvider.Factory
in the
Fragment
- that way I could pass a different VMP.Factory and test the
Fragment
in isolation without Koin. E.g.,
Copy code
class MyFragment(
    private val factory: ViewModelProvider.Factory,
) : Fragment() {
    private val vm by viewModels { factory }
}
The
FragmentFactory
is working well with current set-up but I still need to use the Koin methods to access a VM, which creates a dependency between the Fragment and Koin. 🤔
K 1
a
ok interesting 🤔 Not really taken into account for now 😕