[英]How to apply an annotation to a Koin module dependency declaration?
I have the following Koin module: 我有以下Koin模块:
val exampleModule = module {
single<ExampleRepository> { RealExampleRepository() }
}
I need to apply two annotations to RealExampleRepository
to supress an experimental coroutines API usage warning. 我需要对
RealExampleRepository
应用两个注释,以禁止实验性协程API使用警告。
The annotations I need to apply are: 我需要应用的注释是:
@FlowPreview
@ExperimentalCoroutinesApi
How can I do this? 我怎样才能做到这一点?
I found that it can be done by converting the module to a method and applying the annotations to the method like so: 我发现可以通过将模块转换为方法并将注释应用于方法来实现,如下所示:
@FlowPreview
@ExperimentalCoroutinesApi
fun exampleModule() = module {
single<ExampleRepository> { RealExampleRepository() }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.