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

Prevent to implement OnChanges and DoCheck on the same class #560

Closed
rafaelss95 opened this issue Apr 16, 2018 · 5 comments
Closed

Prevent to implement OnChanges and DoCheck on the same class #560

rafaelss95 opened this issue Apr 16, 2018 · 5 comments

Comments

@rafaelss95
Copy link
Collaborator

According to DoCheck#description:

Note that a directive typically should not use both DoCheck and OnChanges to respond to changes on the same input, as ngOnChanges will continue to be called when the default change detector detects changes.

I thought it was a good idea to add a rule to prevent this.

@wKoza
Copy link
Collaborator

wKoza commented Apr 16, 2018

It makes sense. 👍

@rafaelss95
Copy link
Collaborator Author

@wKoza Do you have any name in mind for this rule?

@mgechev
Copy link
Owner

mgechev commented Apr 17, 2018

no-conflicting-life-cycle-hooks?

@rafaelss95
Copy link
Collaborator Author

I like this name. I'm implementing it right now. Do you think this rule needs to be made in a generic way to provide flexibility or only for DoCheck and OnChanges hooks?

@kylekatarnls
Copy link

My 2 cents, an important part of this quote is "on the same input"

Using OnChanges and DoCheck to respond to independent changes is a relevant usage.

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

No branches or pull requests

4 participants