by default overriding is disabled for safety reason.
null
or
false
behave the same, I should look into it to see there is some good reason for the double possible values. Meanwhile
true
will provide overriding of existing bindings. Its mostly useful when you are using modules or even mocking your dependencies for unit testing
m
Marc Knaup
03/13/2020, 8:43 AM
According to the KDoc there’s also a “may override” option.
Maybe it’s different depending on
silentOverrides
?
I have a case where a Kodein instance can either be created in a “parent scope” or without one. In that case I may or may not need to override something in the parent scope’s Kodein instance that I extend.
I can’t know at this point if I will override something, so
true
will fail if I don’t.
Or well I could know if I explicitly request an optional instance from the Kodein instance that I extend, but that has side-effects.
Right now eventual overrides are only possible by allowing silent overrides for all bindings.
r
romainbsl
03/13/2020, 9:09 AM
Yes, unfortunately, this the only way to use Kodein in such a case, where you won’t be able to know in advance, if you will need overriding or not.