Matt Rea
10/25/2018, 8:52 PMsingle
declaration in your module? If you’re doing single<ComponentA>()
, I would change it to single { ComponentA(get(), get()) }
. Omitting parameters and having koin find them is experimental. As far as I can tell from the source code its based on reflection
https://github.com/InsertKoinIO/koin/blob/e159f2dd845990a9b5588d142692d132d7597708/koin-projects/koin-core/src/main/kotlin/org/koin/core/instance/InstanceHolder.kt
Here’s a Retrofit example in my app
val networkModule: Module = module {
single { createWebApi<AuthApi>(get<NetworkClient>().defaultRetrofit) }
single { createWebApi<MapBoxApi>(get<NetworkClient>().mapBoxRetrofit) }
}
inline fun <reified T> createWebApi(retrofit: Retrofit): T = retrofit.create(T::class.java)
GurpreetSK
10/26/2018, 6:22 AM