So it appears
SortableMixin disappeared from Ember 2.0.
It came out as a surprise as there is nothing on it in 1.x deprecations, nor in any of the individual release notes. It did not raise a deprecation warning in my project either. Only thing I could find is the commit that says “Remove Ember.SortableMixin” and that’s it. Even searching the web for “SortableMixin ember deprecated” yields no result. Actually, the latest topics mentionning it on this very forum still recommend using it.
So, alright then, what is the migration path for that? I hear there is a
Ember.computed.sort, but it is nowhere as versatile. Especially, I need the following features that were available with
- dynamically changing the sorting key.
- using multiple keys for splitting ties (people with same name are sorted by birth date).
- dynamic re-ordering when item properties change.
- not re-sorting the whole array at every insertion. It has a couple thousand items.
Basically, what I used to get with
SortedArray = Ember.ArrayProxy.extend(Ember.SortableMixin)
From what I have seen, 1 and 2 can be achieved using a custom sort function. However, when doing so, there is no way to get the 3, as
Ember.computed.sort does not setup observers when given a custom sort function.
I could define a manual property but, again, as dependency declaration is static, there is no way to get both 1) and 3). I guess I could manage observers and bindings manually but then I’m just reimplementing my own
It would be great if someone had:
- A few hints of what the thinking behind the removal of
- Any clue on the Ember 2.0 way to reach the same goal?
- As my default approach would be to re-implement something similar starting from
ArrayProxy, it would be great to know if it’s here to stay, or if I may find it gone soon? I rely on it quite a lot as I find it convenient to encapsulate and abstract out array transformations.
Thanks for your time.