I have a simple property on an Ember object that I want to run some value checks on before actually setting and triggering/canceling the change. I’m not having much luck finding any code samples or info on this. The pattern I’m used to from other frameworks is to do it within the setter – something like:
Within an Ember Object
propertyName : function(key, value) {
// Setter
if (arguments !== 1) {
if (setCheckHere) {
return this._super(key, value); // ?? is this right?
}
// ?? if ignoring what should I return instead?
}
}.property()
I’m having trouble figuring out what methods I should be calling and what needs to be returned.
My proposal would be the following, see http://jsfiddle.net/pangratz666/NUTAz/:
UPDATE
A even better solution would be to use a closure as @mraken suggests, see http://jsfiddle.net/pangratz666/Zacfh/: