rxjs-tslint-rules
rxjs-tslint-rules copied to clipboard
Support for class inheritance on rxjs-prefer-angular-takeuntil
It's possible to add support for class inheritance on the rxjs-prefer-angular-takeuntil rule? In the current projects i work on, all the common logic of a component is added on a BaseComponent where the subject is defined and called on the ngOnDestroy method. This method may our may not be overrided on the extended component.
An example of the most simple example is visible bellow.
export abstract class BaseComponent implements OnDestroy {
public destroy: Subject<void> = new Subject();
ngOnDestroy() {
this.destroy.next(true);
this.destroy.complete();
}
}
@Component({
selector: "correct-component"
})
class CorrectComponent extends BaseComponent implements OnDestroy {
someMethod() {
a.pipe(
switchMap(_ => b),
takeUntil(this.destroy)
).subscribe();
}
ngOnDestroy() {
super.ngOnDestroy();
}
This same BaseCompoment may also be extended to another abstract component for more specific logic; example bellow.
export abstract class BaseComponent implements OnDestroy {
public destroy: Subject<void> = new Subject();
ngOnDestroy() {
this.destroy.next(true);
this.destroy.complete();
}
}
export abstract class BaseFormComponent extends BaseComponent implements OnDestroy {
(....generic form logic....)
public ngOnDestroy() {
super.ngOnDestroy();
(....generic form logic....)
}
}
@Component({
selector: "correct-form-component"
})
class CorrectFormComponent extends BaseFormComponent implements OnDestroy {
someMethod() {
a.pipe(
switchMap(_ => b),
takeUntil(this.destroy)
).subscribe();
}
ngOnDestroy() {
super.ngOnDestroy();
}
}
I imagine this would be possible, but complicated and I can't see myself having the time to do this anytime soon.
Is there any chance you add this enhancement soon?
Is there any chance you add this enhancement soon?
No. It's simply not a priority for me.