You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
throws org.koin.core.error.DefinitionOverrideException: Already existing definition for [Singleton:'dev.schuberth.stan.exporters.ExcelExporter',binds:dev.schuberth.stan.exporters.Exporter] at dev.schuberth.stan.exporters.Exporter::_root_.
should also throw a DefinitionOverrideException because you're binding two implementations to the same interface and Koin doesn't know which one to inject. It seems to pick the second one but
that's not a documented behavior and
it makes the first bind obsolete so why add it in the first place (ok I know what you're trying to do but outside of your use case, having these two binds in one module doesn't make sense)?
ok I know what you're trying to do but outside of your use case, having these two binds in one module doesn't make sense
Yes, as you know from my SO question I'm looking at Koin from a Service Locator / plugin registry perspective. And there, it makes sense to be able to bind multiple implementations to the same interface, so all plugin instances could be retrieved via app.koin.getAll<Exporter>(). If that shouldn't be allowed, what's the purpose of the getAll() API call after all?
ok I know what you're trying to do but outside of your use case, having these two binds in one module doesn't make sense
Yes, as you know from my SO question I'm looking at Koin from a Service Locator / plugin registry perspective. And there, it makes sense to be able to bind multiple implementations to the same interface, so all plugin instances could be retrieved via app.koin.getAll<Exporter>(). If that shouldn't be allowed, what's the purpose of the getAll() API call after all?
Yes you're right, I didn't understand that Koin indeed allows to inject multiple implementations that can be retrieved into a list .
sschuberth
changed the title
Using constructor DSL to bind mutiple classes via lambdas to the same interface does not work
Using constructor DSL to bind multiple classes via lambdas to the same interface does not work
Nov 7, 2022
Describe the bug
The code
throws
org.koin.core.error.DefinitionOverrideException: Already existing definition for [Singleton:'dev.schuberth.stan.exporters.ExcelExporter',binds:dev.schuberth.stan.exporters.Exporter] at dev.schuberth.stan.exporters.Exporter::_root_
.Note that using the alternative operator-syntax
works.
To Reproduce
Just use above code snippets.
Expected behavior
{ bind<Exporter>() }
syntax should work just likebind Exporter::class
syntax.Koin project used and used version (please complete the following information):
koin-core version 3.2.2
Additional moduleDefinition
n/a
The text was updated successfully, but these errors were encountered: