Here is the scenario
dep = function(){
cannot put any "this" here
}
obj = DS.Model.extend({
response: DS.attr(),
cp: Ember.computed(dep(), function(){ ...})
});
the computed property is known only after the model has loaded ; the response is a json field, containing various keys. I want dependency on parts of the json, what exact part is known after the model is loaded
the dep() function would need to have access to "this" but it does not work if it is defined outside the create instruction, and it does not work if it is defined as a computed property either for instance
obj = DS.Model.extend({
response: DS.attr(),
dep:Ember.computed('response', function(){
some computation
and for instance
return 'response.path1{a,b}';
}),
cp: Ember.computed('dep', function(){ ...})
});
does not work either because dep is not changing from just 'response' dependency, we would need to apply the same dependency on cp and dep which is tautological, and dep would not be needed
Another thing that does not work is
obj = DS.Model.extend({
response: DS.attr(),
cp: Ember.computed(this.dep(), function(){ ...}),
dep(){ this.get('response')... }
});
So does any one knows how to set the dependent keys of a computed property at run time, with a computation dependent on a Model instance
thanks
Aucun commentaire:
Enregistrer un commentaire