https://kotlinlang.org logo
#android
Title
# android
k

kirillrakhman

05/24/2017, 5:24 PM
I tried the following:
Copy code
@Binds @IntoMap @ClassKey(UserViewModel::class)
        abstract fun bindUserViewModel(vm: UserViewModel) : UserViewModel

        @Binds @IntoMap @ClassKey(UserViewModel::class)
        abstract fun bindUserViewModel(vm: UserViewModel) : ViewModel

        @Binds @IntoMap @ViewModelKey(UserViewModel::class)
        abstract fun bindUserViewModel(vm: UserViewModel) : UserViewModel

        @Binds @IntoMap @ViewModelKey(UserViewModel::class)
        abstract fun bindUserViewModel(vm: UserViewModel) : ViewModel
where
Copy code
@MustBeDocumented
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
@MapKey
annotation class ViewModelKey(val value: KClass<out ViewModel>)
k

kingsley

05/24/2017, 5:28 PM
kirillrakhman: You can check this article. Maybe it can help: http://frogermcs.github.io/activities-multibinding-in-dagger-2/
k

kirillrakhman

05/24/2017, 5:29 PM
I did and I believe I'm doing the same
k

kingsley

05/24/2017, 5:32 PM
kirillrakhman: Ah. Okay. You'd need to actually provide the map in one of your modules.
k

kirillrakhman

05/24/2017, 5:33 PM
where does this happen in the linked article?
k

kingsley

05/24/2017, 5:35 PM
Notice the mock application is providing its own implementation manually. An actual application on the other hand should register a module that provides it. So that it'll be injected in the application's onCreate