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
Many of the Container class fields should be protected instead of private. The current implementation of the Container class actually does not expose any way to "extend"/"improve"/"adjust to customer needs", because it is not possible to do anything more than is exposed via its public API.
I would like to extend the Container class and have access to more advanced API, like _bindingDictionary
Current Behavior
Even I create a class MyContainer which is derived from class MyContainer I am not able to access its internal.
class MyContainer extends Container {
get bindings() {
return this._bindingDictionary; // not possible
}
}
Possible Solution
change access modifier of Container class fields from private to protected.
Not only for _bindingDictionary and not for each current private, but probably the vast majority of its private should be protected.
Steps to Reproduce (for bugs)
n/a
Context
I am not able to extend the functionality of Container class, the current implementation is almost identical to the one that would have sealed modifier.
Your Environment
Version used: n/a
Environment name and version (e.g. Chrome 39, node.js 5.4): n/a
Operating System and version (desktop or mobile): n/a
Link to your project: n/a
Stack trace
n/a
The text was updated successfully, but these errors were encountered:
Hey @tutok,
I know this issues is old, but have you found a workaround different from the one I present in #1584 ? Also, have you started working on proposing a PR for this ? If so, would be happy to help and collaborate.
Hey @tutok , @c100k , I'm giving some love to the project again.
I am afraid the container is not so simple. The binding dictionary is private for some very good reasons:
You should never update it manually without relying in the container public API.
The _bindingDictionary does not necesarily represent a real binding dictionary since ancestor containers might have _bindingDictionary properties which, all together can be used to build the real binding dictionary.
I don't think we should expose this dictionary for now. We might extend the container API with a getAllBindngs method instead to provide what you guys expect from _bindingDictionary.
The same could probably be discussed regarding other private fields. Talking about every private field of a container is way out of the scope of a single issue, I'll close this one for now. Feel free to discuss specific properties like _bindingDictionary in #1584
Many of the
Container
class fields should beprotected
instead ofprivate
. The current implementation of theContainer
class actually does not expose any way to "extend"/"improve"/"adjust to customer needs", because it is not possible to do anything more than is exposed via itspublic
API.InversifyJS/src/container/container.ts
Line 19 in f65cacf
Expected Behavior
I would like to extend the
Container
class and have access to more advanced API, like_bindingDictionary
Current Behavior
Even I create a class
MyContainer
which is derived from classMyContainer
I am not able to access its internal.Possible Solution
change access modifier of
Container
class fields fromprivate
toprotected
.Not only for
_bindingDictionary
and not for each currentprivate
, but probably the vast majority of itsprivate
should beprotected
.Steps to Reproduce (for bugs)
n/a
Context
I am not able to extend the functionality of
Container
class, the current implementation is almost identical to the one that would havesealed
modifier.Your Environment
Stack trace
n/a
The text was updated successfully, but these errors were encountered: