-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement post instanciation method call on service #20
Conversation
*/ | ||
Call.prototype.trigger = function trigger(container, instance) { | ||
if (!instance[this.methodName]) { | ||
throw new Error('Can\'t call the given method: "' + this.methodName + '" does not exist on the given instance.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... we will never know until runtime that the method is unknown isn't it? So... the big question is... do we have to be able to launch some kind of checks at container's instanciation? In this case we maybe should collect all checks in a heap and delegate the exception throwing to a dedicated class that will be specialized in heap checks assertions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've add check on container initialization. These check stay "just in case".
@@ -15,6 +15,11 @@ var Container = function Container(serviceDefinitionCollection, parameterCollect | |||
this.parameterCollection = parameterCollection; | |||
|
|||
this.serviceStorage = new ServiceStorage(); | |||
|
|||
if (process.env.NODE_ENV === 'development') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, instead of being hard coupled to NODE_ENV
here... this could become an argument of the Container constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like:
function Container(serviceDefinitionCollection, parameterCollection, boolean: validateDefinitions)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ho 😱 That's a really good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will need to add it to the ContainerFactory
too.
LGTM, good to squash then merge! 👍 |
Implement post instanciation method call on service
ServiceArgumentCollection
toArgumentCollection
andServiceArgument
toArgument