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

Pedro Francisco de Sousa Neto

03/08/2024, 3:36 PM
How can I handle this case?
Copy code
@Single
class Item1(
    @InjectedParam private val xpto: MyClass, <<<<
)

@Single
class MyComponent(
    @InjectedParam private val xpto: MyClass, <<<<
    private val item1: Item1
)
https://insert-koin.io/docs/reference/koin-annotations/definitions#injected-parameters-with-injectedparam
a

arnaud.giuliani

03/08/2024, 6:48 PM
You mean chaining injections?
p

Pedro Francisco de Sousa Neto

03/08/2024, 9:03 PM
Yeah... but I think this is not making sense... The idea it will replace/reuse the same injection (equal to both classes). I avoid it right now moving to a function and invoking the dependency inside this function.
Other question, how can I do this in constructor level?
Something like:
Copy code
@Factory
internal class Repository(
    @Named("mock-remote") private val mock: Mock
): RemoteDataSource
3 Views