Hey everyone .. im new to Koin Annotations .. im p...
# koin
a
Hey everyone .. im new to Koin Annotations .. im planning on migrate my project to use annotations .. im heavily using multi module achitecture libraries for every feature and microservice .. and all those modules is compiled to AppModule I have a scenario like this .. I used to instantiate a Ktorfit module on AppModule/Parent module .. like this ..
Copy code
val ktorfitModule = module {
    single<Ktorfit> {
        ktorfit {
        // my config
        }
    }
}
then i used the ktorfit singleton in my child/service module like this
Copy code
single<AuthService> {
        val ktorfit : Ktorfit = get()
        ktorfit.create()
    }
and it works and compiled without any issue .. but when i try to do with annotations AppModule
Copy code
@Module(includes = [ServiceAuthModule::class])
@ComponentScan("com.ft.ats")
class AppModule {
    @Single
    fun getKtorfit(): Ktorfit {
        return ktorfit {
            // my config
        }
    }
}
Service Module
Copy code
@Module
@ComponentScan("com.ats")
class ServiceAuthModule {
    @Single
    fun authService(ktorfit: Ktorfit) : AuthService = ktorfit.create()

    @Single
    fun getRepository(service: AuthService) : AuthRepository = AuthRepositoryImpl(service)
}
now its not compiled .. im using this method both with Hilt and koin dsl without annotations and it has no problem .. what am i missing ?
Seems like it works if i turn the koin_check off .. but i want to have compile checking feature
p
In the KSP compile safety verification, what is the error? I didn't get it.
a
Ktorfit instance is not created or not found in auth service lib/module .. eventho i already create a singleton in appModule
p
Did you load the module in your
startKoin
? Something like:
startKoin { modules(ServiceAuthModule().module) }
a
I already try it .. i also try to include the servicemodule into AppModule
a
what is not found by the KSP check?
a
the abstraction of the ktorfit interface i defined in AppModule
a
is the type created inside Koin?
perhaps you have missed something in your config
same 1