OnDestroy override issue - Angular 9+
See original GitHub issueπ bug report
Affected Package
The issue is caused by package **@angular/core**Is this a regression?
Yes, the previous version in which this bug was not present was: **Angular 8**Description
Consider a @Component what implements OnDestroy, on the constructor there is a case I must set the following code:
this.OnDestroy = ()=>{ alert(βInvokeβ); }
On Angular 8, it use to work, but somehow in Angular 9 (maybe its IVE issue) that not entering to the override func, instead it entering to the initial implemented func.
Can you explain why and if it really a bug?
π Your Environment
Angular Version:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.901.6
@angular-devkit/core 9.1.6
@angular-devkit/schematics 9.1.6
@schematics/angular 9.1.6
@schematics/update 0.901.6
rxjs 6.5.4
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
A Deep Dive into Angular's NgOnDestroy - Wesley Grimes
NgOnDestroy is a lifecycle method that can be added by implementing OnDestroy on the class and adding a new class method named ngOnDestroy...
Read more >angular - Ensure super.onDestroy() in derived component
Most OOP languages dont offer the feature that you are looking for. Once a method is overriden by a child class, there is...
Read more >OnDestroy - Angular
A lifecycle hook that is called when a directive, pipe, or service is destroyed. Use for any custom cleanup that needs to occur...
Read more >How to auto-unsubscribe in Angular 9 | by Andres Gesteira
We are going to need to modify a property that belongs to cmp : onDestroy . The problem is that that property is...
Read more >How to Share Lifecycle Methods Between Components in ...
Fortunately, that's possible, as of Angular 9; simply remove BaseComponent 's @Component selector property and it won't register a new tag.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is kind of a duplicate of https://github.com/angular/angular/issues/30497, which is fixed by https://github.com/angular/angular/pull/35464. But in your case, you appear to be changing the
onDestroy()
method on the instance, whereas that PR will only allow you to change the method on the prototype.I think you could workaround this right now by creating your class like:
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.