afollestad/ulfberht

@IntoMap capabilities

afollestad opened this issue · 0 comments

A simple case:

@Module
abstract class MyModule1 {
  @Provides @IntoMap("one") 
  fun stringOne(): String = "hello, "
}

@Module
abstract class MyModule2 {
  @Provides @IntoMap("two")
  fun stringTwo(): String = "world!"
}

...

@Inject lateinit var strings: Map<String, String> // ["one": "hello, ", "two": "world!"]

A qualified case:

@Module
abstract class MyModule1 {
  @Provides @IntoMap("test", "one") 
  fun stringOne(): String = "hello, "
}

@Module
abstract class MyModule2 {
  @Provides @IntoMap("test", "two") 
  fun stringTwo(): String = "world!"
}

...

@Inject("test") lateinit var strings: Map<String, String> // ["one": "hello, ", "two": "world!"]