I have a computed observable that looks like this:
this.isActive = ko.computed<boolean>(function () {
this.structure().valueSets();
return this.structure().containsValueSet(this.valueSet());
}, this);
this.structure() is an instance of a StructureVM class (I'm using TypeScript). The containsValueSet function inside the StructureVM class looks like this:
containsValueSet(valueSetVM:ValueSetVM):boolean {
var valueSet:ValueSetVM = _.find(this.valueSets(), function (valueSet:ValueSetVM) {
if (valueSet.id === valueSetVM.id) {
return true;
}
});
return (Objects.isInstantiated(valueSet));
}
I'm using _.find on a list of ValueSetVM (this.valueSets()).The computed does not get updated when something is added to the valueSets array. Why is that? I'm assuming there is something wrong with the dependency chain?
Is it due to my usage of underscore?
Kind Regards,
DenEwout.