I have a requirement where in I have a class in Angular that extends a Base class. Now, there is the feature Toggle Service that I am using to check for a feature.
If it is toggled on, I invoke super with param1 say super(param1)
If it is toggled off, I will invoke it like super(param2)
export class Example extends BaseClass {
constructor(featureToggleService: FeatureToggleService) {
let featureEnabled: boolean;
featureToggleService.check('FEATURE').pipe(map(enabled) => {
if (enabled) {
featureEnabled = true;
}
});
if (featureEnabled) {
super(param1);
} else {
super(param2);
}
}
}
For some reason I don't think it's the correct way, but I have this requirement of invoking super with the param dynamically. Anyone got any views on this? Please share in that case.