-
Notifications
You must be signed in to change notification settings - Fork 136
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
Added dependency resolution modes #21
Conversation
To run the coverage, use |
Here's the culprit: https://coveralls.io/builds/11854857/source?filename=lib%2FcreateContainer.js#L137 You sure its needed? |
Ah yes. No, that method is no longer needed. I meant to remove it and just forgot. One moment. |
Removed unneeded has routine
Updated. You should see 100% coverage come through here soon. Let me know if there is anything you want changed in my implementation. |
I'm going to review & merge tomorrow, probably edit the readme. I want to make sure we don't overwhelm the first-time reader by explaining all the configuration methods in the introductory example. I think the new Resolution Mode deserves its own section. 😄 Nice work! 🎊 |
Sounds good to me! Thanks a ton! The code in there is well-written so it was an easy addition. |
@@ -731,7 +747,7 @@ The `['glob', Lifetime.SCOPED]` syntax is a shorthand for passing in registratio | |||
|
|||
Clone repo, run `npm i` to install all dependencies, and then `npm run test-watch` + `npm run lint-watch` to start writing code. | |||
|
|||
For code coverage, run `npm run coverage`. | |||
For code coverage, run `npm run cover`. |
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.
My bad, didn't realize I put coverage
instead of cover
.
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.
It's cool. I figured I'd take care of it for you!
lib/loadModules.js
Outdated
@@ -39,7 +40,8 @@ module.exports = function loadModules (dependencies, globPatterns, opts) { | |||
opts = opts || {} | |||
opts = Object.assign({}, { | |||
registrationOptions: { | |||
lifetime: Lifetime.TRANSIENT | |||
lifetime: Lifetime.TRANSIENT, | |||
resolutionMode: ResolutionMode.PROXY |
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.
Might want to consider pulling the default from the container. For example, by passing it into opts
.
lib/registrations.js
Outdated
* The function that constructs the specified type | ||
*/ | ||
function buildNewClassFunction (Type) { | ||
return (dependencies) => { |
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.
If anything, you can use return function () {}
and use arguments
.
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 am not sure why I didn't try using arguments
, it ended up working way better. Thanks!
lib/registrations.js
Outdated
return function (container) { | ||
// Because the container holds a global reolutionMode we need to determine it in the proper order or precedence: | ||
// registration -> container -> default value | ||
let resolutionMode = (this.resolutionMode || container.__resolutionMode || ResolutionModes.PROXY) |
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 we should have a container.options
where things like the default resolutionMode
are used, so accessing them don't seem like a hack (the __
in the name indicates "private"). Thoughts?
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 agree with having options
on the container. I was thinking along those lines but you weren't storing the options on the container before so I didn't know if that would be too much. The __
was intentional so hopefully no one would use the property haha.
I will make the other changes as well.
These comments I just left are things I could take care of, too - not trying to rub all the work off on you! 😄 |
@jeffijoe I am in a lucky position at the moment. Tomorrow is my last day at work and they basically said to "Do whatever you want" so I am doing this. I will take care of these issues! It keeps me busy and makes me feel like I am contributing to the community. |
That sounds great, I'll hold off on the review and edits then! Feel free to hop on the Awilix gitter, I try to be around as much as possible. I'm off for now though, thanks again! |
@jeffijoe Updated for review whenever you return. |
lib/registrations.js
Outdated
// Use a regular function instead of an arrow function to facilitate binding to the container object | ||
return function (container) { | ||
// Because the container holds a global reolutionMode we need to determine it in the proper order or precedence: | ||
// registration -> container -> default value | ||
let resolutionMode = (this.resolutionMode || container.__resolutionMode || ResolutionModes.PROXY) | ||
let resolutionMode = (this.resolutionMode || container.options.resolutionMode || ResolutionModes.PROXY) |
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.
Not sure if this is enforced in the linter, but if you don't modify a variable after initialization, you should use const
, it communicates intent and the reader will know that it won't be modified. 😄 I can fix these no problem, just letting you know.
Made a few modifications + readme updates and other small things, feel free to review my commits! Released as 2.3.0 on npm. Again, great work @cjhoward92! Are you on Twitter? I wanna give a shoutout. 😄 |
See issue #11 for details.
Examples related to transpiling can be found in the examples folder under
typescript
andbabel
.Code coverage is ~99.62%. I cannot find the last line.
coveralls
was not working for me.