I'm using Emberfire in my app, and I'm trying to findAll
stats, and then sort that model by a key, like in the following example. But, when I sort this way I lose the ability to see real time updates in my template and I have to reload the page to see the new/updated data in the view.
model() {
return this.store
.findAll('stats', {
reload: true,
backgroundReload: true
})
.then(stats => stats.sortBy('date'));
}
You have to define a computed property at your controller or a component, which returns the sorted stats. Do not sort your data at route's model hook. Just return the promise of findAll.
For example:
Furthermore ember offers a sort macro:
By using it you can solve your requirement more elegant: