`overrides = null` and `overrides = false` are not...
# kodein
m
overrides = null
and
overrides = false
are not documented. From testing, it looks like that •
true
requires an override •
false
disallows an override •
null
disallows an override So this doesn’t seem correct:
@param overrides Whether this bind **must**, **may** or **must not** override an existing binding.
I suggest using an enum here for clarity 🙂
r
Thanks for the suggestion, we are always looking for improvements.
However there is a documentation about overriding here https://kodein.org/Kodein-DI/index.html?latest/core#_overriding
m
That’s what I’m referring to. It only covers the
true
case.
r
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
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
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.
😢 1