Hello! I'd like to do the following with Koin. W...
# koin-contributors
p
Hello! I'd like to do the following with Koin. We have: 1. isolated Koin component, 2. an interface with getters (or properties) for other interfaces:
Copy code
interface Dependencies {
    val dependency0: Dependency0
    val dependency1: Dependency1
...
}
The interface is provided to Koin outside. We want to use DependencyX as a usual singleton dependency. For now, we have to wrap each dependency into single() function. But this is not convenient: if we change Dependencies interface, we must change the module. It would we great if Koin can use externally provided dependencies as his dependencies. Motivation: component holder pattern https://proandroiddev.com/modularization-of-android-applications-in-2021-a79a590d5e5b I tried to implement it, but the solution is weird. At least because I had to use internal property "definitions": https://github.com/PavelSidyakin/WeatherForecast/blob/koin_experiments/feature/city_list/src/main/java/com/example/city_list/di/CityListComponentImpl.kt Would you implement the functionality in the library? Or I can try to implement it. Can you recommend how to do it better?
Tried to implement it in Koin. But reflection api is not fully available in multiplatform (I can't get class's members, for example). So, it's not possible for now. The only option is to map the dependencies manually.
a
You can take a look at
koin-core-ext
which is using Java reflect to help build instance from type