Hugo Bernardi
11/26/2024, 3:58 PMUseCase
annotated with @Single
, Module B has a ViewModel annotated with @KoinViewModel
injecting UseCase
and Module DI adds A and B and startKoin
Is it possible to isolate Koin Configuration (ksp application) in the module DI and then have something like this :
@Module
@ComponentScan("moduleA.package")
class ModuleA
@Module
@ComponentScan("moduleB.package")
class ModuleB
startKoin {
modules(ModuleA().module, ModuleB().module)
}
Edit: I was reading this article but I didn't manage to make it workarnaud.giuliani
11/26/2024, 5:36 PMisolate Koin ConfigurationLike with IsolatedContext ?
Hugo Bernardi
11/26/2024, 6:59 PMHugo Bernardi
11/26/2024, 7:33 PM@ComponentScan
annotation, KSP traverses accross all Gradle modules for the same package. (since 1.4)
But the generated Koin Module stays empty
public val template_di_ModuleA : Module get() = module {
}
Gradle Module DI (KMP) :
// in build.gradle.kts
apply(ksp)
implementation(ModuleA)
implementation(ModuleB)
// [...] Other Koin annotation configuration..
// Expose a KoiHelper object to startKoin
object KoinHelper {
fun init(block: KoinApplication.() -> Unit) {
startKoin {
modules(ModuleA().module)
block()
}
}
}
// Create a Module
@Module
@ComponentScan("moduleA.package")
class ModuleA
Gradle Module A :
package moduleA.package
@Single MyUseCase { }
I think I'm missing somethingarnaud.giuliani
11/27/2024, 8:56 AM