Refer the following code which I have taken from NET for auto subscribing:
export function AutoUnsub() {
return function (constructor: any) {
const orig = constructor.prototype.ngOnDestroy;
constructor.prototype.ngOnDestroy = function () {
for (const prop in this) {
const property = this[prop];
if (typeof property.subscribe === "function") {
property.unsubscribe();
}
}
orig.apply();
};
};
}
The lint issues are as follows:-
Line 2: non-arrow functions are forbidden.
Line 2: spaces before functions parens are disallowed
line 5: for (...in...) statements must be filtered with an if statement.
3rd issue, I can't put a space. The same goes away on save. Seems related to some settings in VScode.