Skip to content
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

Merged
merged 16 commits into from
Jun 7, 2017
Merged

Conversation

cjhoward92
Copy link
Contributor

See issue #11 for details.

Examples related to transpiling can be found in the examples folder under typescript and babel.

Code coverage is ~99.62%. I cannot find the last line. coveralls was not working for me.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 99.611% when pulling 3922a67 on cjhoward92:master into 8f3ae97 on jeffijoe:master.

@jeffijoe
Copy link
Owner

jeffijoe commented Jun 6, 2017

To run the coverage, use npm run cover- npm run coveralls is used by CI.

@jeffijoe
Copy link
Owner

jeffijoe commented Jun 6, 2017

Here's the culprit: https://coveralls.io/builds/11854857/source?filename=lib%2FcreateContainer.js#L137

You sure its needed?

@cjhoward92
Copy link
Contributor Author

Ah yes. No, that method is no longer needed. I meant to remove it and just forgot. One moment.

Carson.Howard and others added 2 commits June 6, 2017 12:37
@cjhoward92
Copy link
Contributor Author

Updated. You should see 100% coverage come through here soon. Let me know if there is anything you want changed in my implementation.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 098a92a on cjhoward92:master into 8f3ae97 on jeffijoe:master.

@jeffijoe
Copy link
Owner

jeffijoe commented Jun 6, 2017

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! 🎊

@cjhoward92
Copy link
Contributor Author

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`.
Copy link
Owner

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.

Copy link
Contributor Author

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!

@@ -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
Copy link
Owner

@jeffijoe jeffijoe Jun 6, 2017

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.

* The function that constructs the specified type
*/
function buildNewClassFunction (Type) {
return (dependencies) => {
Copy link
Owner

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.

Copy link
Contributor Author

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!

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)
Copy link
Owner

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?

Copy link
Contributor Author

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.

@jeffijoe
Copy link
Owner

jeffijoe commented Jun 6, 2017

These comments I just left are things I could take care of, too - not trying to rub all the work off on you! 😄

@cjhoward92
Copy link
Contributor Author

@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.

@jeffijoe
Copy link
Owner

jeffijoe commented Jun 6, 2017

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!

@cjhoward92
Copy link
Contributor Author

@jeffijoe Updated for review whenever you return.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0fa6b22 on cjhoward92:master into 8f3ae97 on jeffijoe:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b1031c1 on cjhoward92:master into 8f3ae97 on jeffijoe:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 9f58bac on cjhoward92:master into 8f3ae97 on jeffijoe:master.

// 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)
Copy link
Owner

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.

@jeffijoe jeffijoe merged commit 9f58bac into jeffijoe:master Jun 7, 2017
@jeffijoe
Copy link
Owner

jeffijoe commented Jun 7, 2017

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. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants