I have a fairly simple CLI app in which I'm trying...
# squarelibraries
m
I have a fairly simple CLI app in which I'm trying to use Dagger/Anvil. I have an interface
Presenter
, and a few implementations of those. E.g.:
Copy code
@ContributesMultibinding(PresenterScope::class, boundType = Presenter::class)
@StringKey("foo")
class FooPresenter @Inject constructor() : Presenter {}
My main file looks like this:
Copy code
class Main @Inject constructor(
  private val presenters: Map<String, Presenter>,
) {}

@Singleton
@MergeComponent(PresenterScope::class)
interface Provider {
  fun main(): Main
}

fun main(args: Array<String>) {
  DaggerProvider.builder().build().main().main(args)
}
The presenters injection fails, Dagger complains that there's no provide method. However, if I declare my provider like this:
Copy code
@Singleton
@MergeComponent(PresenterScope::class)
interface Provider {
  fun main(): Main
  val presenters: Map<String, Presenter
}
There, Dagger is finding it (if I remove it from my
Main
class that is). I feel like I'm missing something obvious to provide that dependency to my
Main
class, but I can't figure out what?