-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support Angular's takeUntilDestroyed operator #16
Comments
+1 to this. Also, there's no need for ngOnDestroy on component which uses angular's destroyRef, but the lint rule still gives "ngOnDestroy" is not implemented warning. |
not perfect, but at least some something: 'rxjs-angular/prefer-takeuntil': [
'warn',
{
alias: ['takeUntilDestroyed'],
checkDestroy: false,
checkComplete: false,
}
], |
For me the alias is not working....
But still getting errors: 132:155 error Forbids calling |
@negberts without code that causes the issue it is hard to diagnose. One thing to check is that the Here is my config working with "rxjs-angular/prefer-takeuntil": [
"error",
{
"alias": ["takeUntilDestroyed"],
"checkComplete": false, // Until https://github.com/cartant/eslint-plugin-rxjs-angular/issues/16 is implemented
"checkDecorators": [ "Component", "Directive", "Pipe", "Service" ],
"checkDestroy": false
}
], |
And the getNominaleKorreldiameters method is like this in the service (doing a HTTP call)
|
Make sure you are on the version of IIRC, you have to turn off And finally, you are getting data out of an Observable in Angular. You should not be using |
@rgant we're using the latest version. I am aware of the AsyncPipe but that would be a massive overhaul of the application. |
Is this feature request under considerations from the maintainers? While the provided workaround works, having a separate rule would likely encourage people to adopt the I would be willing to provide a PR for this feature, if that would help form a decision. Seeing the latest commit being over a year ago and other PRs not getting any attention, I first wanted to reach out if that is even desired from the maintainers (as well as the communities) side. |
The alias workaround is not good for takeUntilDestroy because that way the plugin matches both takeUntil and takeUntilDestroy. So lint passes if your subscription contains either takeUntil or takeUntilDestroy that is not great. In case you forgot to use takeUntilDestroy and instead used takeUntil approach, lint rule stops protecting you because you might forget to call detach.next() in ngOnDestroy or forget to declare ngOnDestroy at all. Out of topic: |
From the rules description:
So yeah, you need to provide |
Thanks for the response! Yes, really, I missed this in docs. Many thanks. |
Angular 16 introduces a new
takeUntilDestroyed()
operator for destroying subscriptions, see their v16 blog post. Theprefer-takeuntil
rule should by default not raise a lint error when this operator is used on a subscription.In the meantime we can add this operator to the
alias
option:The text was updated successfully, but these errors were encountered: