Consider this typescript class (but I don't think Typescript is relevant to the problem, other than obscuring the underlying defineProperty call):
class Model
{
public TeamId: number;
constructor()
{
var self = this;
ko.track(this);
ko.getObservable(this, "TeamId").subscribe(function (newValue)
{
var o = ko.getObservable(self, "link");
o.valueHasMutated();
});
}
get link(): string
{
return `/blah/blah/team/${this.TeamId}`;
}
}
Note that I'm using the mapping plugin.
The link property uses the current TeamId to make a suitable link for that team. My problem is: how do I tell knockout that when the TeamId property changes, so does the link property? I thought that the subscribe callback would do it, but getObservable returns null. I guess this is because it doesn't work with properties defined with defineProperty. But now I'm stuck because I want to use this syntax but can't make it work.