afollestad / ulfberht

🗡️ A small but powerful & opinionated DI library. Written in Kotlin, and powered by annotation processing.

Home Page:https://af.codes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@IntoSet capabilities

afollestad opened this issue · comments

A simple case:

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

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

...

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

A qualified case:

@Module
abstract class MyModule1 {
  @Provides @IntoSet @HelloWorld
  fun stringOne(): String = "hello"
}

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

...

@Inject @HelloWorld lateinit var strings: Set<String>
@Inject @HelloWorld lateinit var providedStrings: Set<Provider<String>>
@Inject @HelloWorld lateinit var providedStrings: Provider<Set<String>>
@Inject @HelloWorld lateinit var providedStrings: Provider<Set<Provider<String>>>

I want to handle injecting a set of providers as well.