https://kotlinlang.org logo
#kodein
Title
t

Tomas Kormanak

02/04/2022, 2:22 PM
Hi, is it possible to have multiple bindings for a single interface. And inject all of them into a class? Something like
Copy code
interface Handler {}
class SomeService(val handlers: List<Handler>) { ... }
Copy code
di {
  bind<Handler> { ActualHandler1() }
  bind<Handler> { ActualHandler2() }

  bind<SomeService> { SomeService(instance())}
}
r

romainbsl

02/04/2022, 4:46 PM
Yes it is , we call it Set binding, you can find the docs here https://docs.kodein.org/kodein-di/7.10/core/multi-binding.html
t

Tomas Kormanak

02/10/2022, 4:55 PM
Thank you!
18 Views