Dagger 2 static provider methods in kotlin

后端 未结 5 1522
梦毁少年i
梦毁少年i 2020-12-05 09:20

With the recent versions of dagger 2 one of the improvements made are the possibility of having static provide methods. Simply so:

@Provides
static A provide         


        
5条回答
  •  孤城傲影
    2020-12-05 10:06

    I can't test it right now, but I think this should work:

    @Module
    object AModule {
        @JvmStatic
        @Provides
        fun providesA(): A = A()
    }
    

提交回复
热议问题