-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
ngOnDestroy
is not implemented raised by prefer-takeuntil rule when ngOnDestroy is in a super class
#1
Comments
ngOnDestroy
is not implemented when it is in a super class in prefer-takeuntil rulengOnDestroy
is not implemented raised by prefer-takeuntil rule when ngOnDestroy is in a super class
See this comment on the TSLint rule equivalent:
|
Thanks for your answer. |
It's safer use
or
|
For both @Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.less'],
})
export class FooterComponent extends BaseComponent implements OnInit {
// Some code
} Or even simpler as an easy / naive way to add support: let us disable the |
@Samuel-Beslogic I just don't have the time to mess with these rules and I've not used them myself lately - as I've not used Angular for years. Rather than messing with them to work with base-class/component shenanigans, maybe the plain vanilla RxJS rules would be a better fit: |
@cartant Part of your rule does something important that neither of those two do: it ensures takeuntil used on subscriptions should properly unsubscribe when the component is destroyed. It's just that there's part of the rule that wrongly assumes all components need to implement OnDestroy by themselves. Even just splitting the takeUntil rule in two (or being able to disable the check for implementing OnDestroy) would be sufficient. I'm willing to spend some time on this and create a PR if I have a working solution. The AST Selector for the extend class would look something like this |
Considering this super class :
In the components extending Destroy, having takeUntil(this.destroyed$) before each subscribe should be enough to fullfill prefer-takeuntil rule.
But there is the following issue :
error `ngOnDestroy` is not implemented rxjs-angular/prefer-takeuntil
The text was updated successfully, but these errors were encountered: