Closed samuelsimoes closed 8 years ago
Yes, makes sense.
The current implementation is very rudimentar, just the basic sort.
Are you thinking in listen the change:$attribute
to reorder?
I vaguely remember that add stores, reset and etc wasn't resorting either.
Today only the add
method reorders the collection. About your suggestion to listen to the attribute to make the ordering I agree, but what API we would use?
Something like this below?
class Foo extends CollectionStore {
static sort = {
on: ["stores:change:name"],
resolve: ((a, b) => a.data.order - b.data.order)
};
}
Can't we just call the order method again (just like backbone)?
This means we would listen to change instead of change:attr.
Performance would be worse but until someone is using thousands of stores, we may not need to worry.
Ok. Listening to the collection change
could the job. 👌 I will submit a patch soon.
When the attribute used to sort the collection store is changed on some children store the collection store doesn't reorder itself.