我正在将应用程序从 Dagger2 移动到 Koin,并且需要在 dagger 下进行转换
@Provides
@Singleton
@Named("refresh")
fun provideRefreshRetrofit(@Named("refresh") okHttpClient: OkHttpClient, gson: Gson): Retrofit {/*...not important...*/}
直到现在:
single<Retrofit> { /*....*/ }
但我需要在同一个模块中有类似的条目。是一种转换/解决/解决方法吗?
最佳答案
见docs .您可以为定义命名
single(name="refresh") { Retrofit.Builder().build() }
并使用它
factory { ClassThatDependsOnRefresh(get("refresh")) }
此处仅以 single 和 factory 作为示例。
关于kotlin - Koin 中 Dagger 的 @Named 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52272307/