What am I doing here wrong? ```const val FORBIDDE...
# koin
r
What am I doing here wrong?
Copy code
const val FORBIDDEN_INTERCEPTOR = "forbiddenInterceptor"
const val USER_AGENT_INTERCEPTOR = "userAgentInterceptor"

single<Interceptor>(named(USER_AGENT_INTERCEPTOR)) {
    get<Interceptor>(named(FORBIDDEN_INTERCEPTOR)) // simulate the need to get the dep
    UserAgentInterceptor()
}
singleOf(::UnauthorizedInterceptor) {
    named(FORBIDDEN_INTERCEPTOR)
    bind<Interceptor>()
}
both interceptors are declared in the same module but it ends up with
Copy code
NoBeanDefFoundException: No definition found for class:'okhttp3.Interceptor' q:' & qualifier:'forbiddenInterceptor''. Check your definitions!
If I change the
UnauthorizedInterceptor
to
single<Interceptor>(named(FORBIDDEN_INTERCEPTOR))
it statrts to work
a
take care to use the right
named
extension in lambda block of
singleOf
. It's comes from OptionDSL here