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

feat(container): add self registration of container in constructor, t… #101

Merged

Conversation

Tolowe
Copy link
Contributor

@Tolowe Tolowe commented Nov 19, 2017

…est, and document it

@basedalexander
Copy link
Member

basedalexander commented Nov 19, 2017

Thank your for the PR, I'll take a look tomorrow.

You can try implementing this one ,
that's a great way to learn one of the most important things in Typescript.

Copy link
Member

@basedalexander basedalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I like this. Please make some changes (where I commented) and I'll merge this.

Keep in mind that master branch is already several commits ahead. If you have any question let's discuss here.

@@ -6,6 +6,8 @@ export interface IContainerOptions {
}

export interface IContainer {
[key: string]: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing that it's a bad practise. Interface (aka super type) should define only public methods. Unless you use interface for defining structure of value objects. Please remove that.

@@ -21,6 +21,7 @@ export class Container implements IContainer {
this.parent = <IContainer> options.parent;
this.defaultLifeTime = options.defaultLifeTime || this.defaultLifeTime;
}
this.register({ token: TContainer, useValue: this });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did right! But I'm gonna release that simplified Reflect API which is gonna allow us to inject stuff by just specifying it's type like this constructor (private container: Container) {}. Please use Container as the token in this case.

it('should register itself for injection', () => {
// arrange, act
const actual = container.resolve(TContainer);
// assert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't deny that comments like this one are obvious. Clearly named variables and methods won't need any comments above them. Please remove them.

@basedalexander
Copy link
Member

@Tolowe Tt's better to just close this PR, then pull changes and then fix yours and open new PR.

@Tolowe
Copy link
Contributor Author

Tolowe commented Dec 2, 2017

@ThoHoh I think I have everything fixed as you mentioned.

@basedalexander basedalexander merged commit 29b765a into typesoft:master Dec 2, 2017
@basedalexander
Copy link
Member

@Tolowe Thank you!

@Tolowe Tolowe deleted the feature/70-self-inject-container branch December 3, 2017 02:27
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.

2 participants