mercredi 25 mars 2015

Sorting ember-data live array in route model hooks

in a ember route's model hook the following works fine:



model: function () {
return this.modelFor('foo').get('bar');
}


Backed by ember-data, I can delete some of foo's bars somewhere else and it will be updated automagically (live array).


Now, I want this to be sorted (and user in sub-routes, so I have to do this in the route, not in the controller).



model: function () {
return this.modelFor('foo').get('bar')
.then(function (data) {
return data.sortBy('baz');
});
},


... does the job only the first time around, because I'm losing the updating.


Is there a way to write automatic updating sorting in line? What is the ember way to solve this?





Aucun commentaire:

Enregistrer un commentaire