I have a computed property and would like to keep track of the its most recent value via the get / set syntax:
myProperty: Ember.computed({
get: function () {
?
},
set: function (key, value) {
let currentValue = this.get('myProperty');
this.set('oldMyProperty', currentValue);
return value;
}
})
However I honestly have no clue what to do with the getter. Calling this.get('myProperty')
will lead to an infinite loop. However using just this.myProperty
doesn't go far enough and just returns the computed property itself, not the value. Is there a way I can omit the getter so it just resolves to the current value?
After talking with the ember community via slack, their suggestion was to maintain an old and new value (perhaps using ES6 Symbols
to avoid accidental references to them). I'm just curious if there's a simpler way that lets the get
just default to normal lookup.
This is what I'm working off of:
http://ift.tt/1S2jpJ0
Aucun commentaire:
Enregistrer un commentaire