Let's say we have a service like this one:
SupermanService {
private _superman: Hero;
public supermanReplaced = new EventEmitter<Hero>();
public supermanPropertyUpdated = new EventEmitter<Hero>();
public get superman(): Hero {
return this._superman;
}
public set superman(superman): void {
this._superman = superman;
this.supermanReplaced.emit(superman);
}
public updateSupermanProperty(key: string, val: string | number): Hero {
this._superman[key] = val;
this.supermanPropertyUpdated.emit(superman);
return this._superman;
}
}
Is there some way to detect supermanPropertyUpdated without using the updateSupermanProperty() function but by e.g. setting this.superman.power = 10?
I found some posts that suggest the KeyValueDiffer in combination with the DoCheck hook, but that is not available for services.