koin icon indicating copy to clipboard operation
koin copied to clipboard

Allow using qualifiers when injecting fragments

Open pikzen opened this issue 5 years ago • 0 comments

Describe the bug using a qualifier when injecting fragments does nothing.

To Reproduce inject a fragment with fragment(named("SwitchableFragment")) { FragmentThatWillBeReplacedSometimes() }, then in another module attempt to override it with fragment(named("SwitchableFragment"), override = true) { ReplacementFragment() }

Expected behavior When using the koin FragmentFactory, the fragment DSL method has the following signature:

Module.fragment(
    qualifier: Qualifier? = null,
    override: Boolean = false,
    noinline definition: Definition<T>
)

However, the default KoinFragmentFactory never makes use of that qualifier. Ideally, I'd be able to inject a named fragment and override it (since injecting an interface is not an option for fragments), and the FragmentFactory would retrieve that one. I'm not sure how it would be possible to pass this named qualifier into the fragment factory though. Passing it through arguments to pass it again into the get() call feels quite brittle.

Koin project used and used version (please complete the following information): Koin 2.1.6

pikzen avatar Sep 09 '20 12:09 pikzen