java - 如何用Kotlin编写Dagger组件?

标签 java kotlin dagger-2

我是 dagger 和 kotlin 语言的新手,我想将下面的 java 代码翻译成 kotlin 代码。这是用 Java 编写的 Dagger 组件。

    @Singleton
    @Component(modules = {ApplicationModule.class, NetworkingModule.class})
    public interface ApplicationComponent {
       public PresentationComponent newPresentationComponent(PresentationModule presentationModule);
    }

最佳答案

可能是这样的,

@Singleton
@Component(modules = [ApplicationModule::class, NetworkingModule::class])
interface ApplicationComponent {
    fun newPresentationComponent(PresentationModule presentationModule): PresentationComponent
}

关于java - 如何用Kotlin编写Dagger组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53887296/

相关文章:

java - 使用改造将压缩图像上传到服务器

java - 如何在 Kotlin 中使用 varargs(参数数量)和反射

android - "Dagger will inject those fields if requested, but will not create new instances"是什么意思?

java - 带有 spring 缓存和 aspectj 的 NoClassDefFoundError

java - 在java代码中执行一个带参数的外部程序

java - 通过Charset确定特殊字符

java - 正确缩进 Java/Kotlin 控制台输出

java - 如果没有 @Inject 构造函数,则无法提供 Dagger 2 对象

android - 将依赖项注入(inject)未打包的对象 - 最佳实践?

java - maven java.lang.NoClassDefoundError Linux