Kotlin multi-platform and implementation independent dependency injection

47 Views Asked by At

I am looking for a Kotlin multi-platform, and implementation independent dependency injection approach. Similar to the Jakarta inject API for Java (https://jakarta.ee/specifications/platform/9/apidocs/jakarta/inject/package-summary.html, which is implementation independent), and Koin (https://insert-koin.io/, which is multi-platform, I am looking for an approach that combines both. Obviously, Jakarta inject is not multi-platform, and Koin is already a specific implementation. My use case is that I am developing a Kotlin multi-platform library in which I do not want to fix a particular DI framework. However, it should define some sensible module configurations, similar to Spring's @Configuration (https://docs.spring.io/spring-framework/reference/core/beans/java/configuration-annotation.html). This library will be plugged into for instance a Spring Boot application (which used spring-context), or in a Ktor application (which uses koin).

One approach I can imagine is that there is a spring-context (and Guice and Dagger) implementation for koin-annotations (https://insert-koin.io/docs/reference/koin-annotations/start/), but such an approach, or similar I could not find.

0

There are 0 best solutions below