Koin not seeming to like my KMP setup for this mod...
# koin
d
Koin not seeming to like my KMP setup for this module: commonMain
Copy code
val inventoryModule = module {
    factory<HttpClient> { (clientFactory: IHttpClientFactory) -> clientFactory.createClient() }
    single<IInventoryManager>{HttpInventoryManager(get())}
    viewModelOf(::InventoryItemViewModel)
}
...
interface IHttpClientFactory {
    fun createClient(): HttpClient
}
In androidMain
Copy code
...
class OkHttpClientFactory(): IHttpClientFactory {
    override fun createClient(): HttpClient {
        return HttpClient(OkHttp)
    }
}
...
actual fun platformModules(): Array<Module> {
    val httpModule = module {
        singleOf<IHttpClientFactory>(::OkHttpClientFactory)
    }
    return arrayOf(
        httpModule
    )
}
back in commonMain
Copy code
KoinApplication(application = {
  modules(
    inventoryModule,
    *platformModules()
  )
})...
All this results in
Caused by: org.koin.core.error.NoParameterFoundException: Can't get injected parameter #0 from DefinitionParameters[] for type 'com.bigballard.tool.http.IHttpClientFactory'
a
here your problem is you declare
factory<HttpClient> { (clientFactory: IHttpClientFactory) -> clientFactory.createClient()
which is asking to pass dynamic parameter
IHttpClientFactory
when resolving
HttpClient
if you wan to look up for a given definition type instead of dynamic parameter, use this instead:
factory<HttpClient> { get<IHttpClientFactory>().createClient() }