Beginning with Ember 1.12, the below code block generates a deprecation warning because of changes to encourage using distinct getters and setters. I understand the concept, but I'm not sure how to refactor something that uses Ember.computed.apply() in such a way that these deprecation warning are resolved.
var args = this.constructor.primaryKeys.concat(function(_, setValue) {
var keyNames = this.constructor.primaryKeys;
if (setValue === undefined) {
var key, value;
for (var i = 0; i < keyNames.length; i++) {
key = keyNames[i];
value = this.get(key);
if (!Ember.isNone(value)) {
return value;
}
}
} else {
if (this.get('primaryKey') !== setValue) {
this.set(keyNames[0], setValue);
}
return setValue;
}
});
var primaryKey = Ember.computed.apply(Ember, args);
Twiddle demonstrating the problem
Aucun commentaire:
Enregistrer un commentaire