can I have a getter which can match 2 different sources?
I have an array of commands.Each command is an object (JSON):
Commands= [{
opCode: anOpCode,
field: aField,// matching the field in html
parser: 'referenceToAfunction',
params:aParam, //the param can be null or have some value
value: null//I have a getter to that value
}, //many other commands...]
The ViewModel (getters from my commands):
Object.defineProperty(VM, aField, {
get: function () {
return Commands.find(function(cmd) {
if(cmd.field == aField)
return cmd.value;
});
}
});
I have some specials commands where 2 different params match the same field in html.
In my array it will be 2 different object (where only params value is different), but I would like the getter to be updated if any of them changes