jeudi 21 septembre 2017

Keep model data sorted?

My Ember data is database-based, but Ember maintains its own copy. So while the CRUD calls return sorted data always, it gets out-of-sort in Ember when data is added. The obvious fix is to have Ember stay in sync with the database, but that seems to violate the premise of Ember, plus there's no obvious "reloadAll" call.

But there's also no obvious "sortBy" that applies from a model. I did try adding a...

phrasesSorted: Ember.computed.sort('phrases', 'phrase')

to my phrases model, but couldn't figure out how to get it referenced from the component (e.g. doesn't do it.)

What's the Embery-way to easily present data sorted? Is this a case where I need to write a bunch more code - e.g. custom routes and controllers - to do something that seems simple, or just me missing the simple?




Aucun commentaire:

Enregistrer un commentaire