Dagger 2 has the ability to injecting set or map with multibindings. How to do it in Toothpick
for example i want
@Inject constructor(val map: Map<String, ISyncRepository>)
Dagger 2 has the ability to injecting set or map with multibindings. How to do it in Toothpick
for example i want
@Inject constructor(val map: Map<String, ISyncRepository>)
it might be like:
@Binds
@IntoMap
@TheMapKey(“your key”)
abstract fun getSyncRepository() : ISyncRepository
Look at the following 2 samples
https://google.github.io/dagger/multibindings.html
https://blog.kotlin-academy.com/understanding-dagger-2-multibindings-viewmodel-8418eb372848
for
@Inject constructor(
private val creators: Map<Class<out ViewModel>, @JvmSuppressWildcards
Provider<ViewModel>>
)
using:
@Binds
@IntoMap
@ViewModelKey(UserViewModel.class)
abstract ViewModel bindUserViewModel(UserViewModel userViewModel);