Sagar Khurana
10/08/2024, 10:05 AM@Single
class ScalefusionRepositoryImpl(
private val foo: Food, // Class annottaions with @Factory
private val bar: Bar, // Defined in the Kotlin DSL module
private val sugar: Sugar, // Defined in the Kotlin DSL module
){
...
}
Annotated Class
@Factory
class Foo{
...
}
Kotlin DSL Module
val coreModule = module {
factoryOf(::Bar)
factoryOf(::Sugar)
}
Error
Missing Definition type 'com.x.y.data.mapper.TestMapper' for 'com.x.y.data.repository.ScalefusionRepositoryImpl'. Fix your configuration to define type 'TestMapper'.
P.S.: Bar and Sugar classes are implementing a generic interface. The only way to bind them with a generic interface is through the Koin DSL approach approach. However, with the annotations, the only way to bind them is using the @Named annotation, which is not the best as I have to pass the names everywhere.Pedro Francisco de Sousa Neto
10/08/2024, 10:54 AMSagar Khurana
10/08/2024, 11:02 AMKoin annotations doesn't see the DSL in project.👍 Can you please elaborate on what you said below? I didn't fully understand
You can also invoke koin to inject them inside your provide function.