backbone-redux
backbone-redux copied to clipboard
Try to save the order of entities when merging new models
Now on every update changed models are removed from the entities
array and updated ones are added to the end of it. This forces user to do a sorting by id (or any other field in the view layer).
It will be great to preserve the initial order of the models on an update.
Ie, this code should pass:
const testSaveOrder = () => {
const initialStore = [
{id: 1, name: 'lol'},
{id: 2, name: 'lol2'},
{id: 3, name: 'lol3'},
];
const newStore = mergeStore(
initialStore,
[
{id: 2, name: 'lol22'},
{id: 4, name: 'lol4'}
]
);
expect(newStore).toEqual([
{id: 1, name: 'lol'},
{id: 2, name: 'lol22'},
{id: 3, name: 'lol3'},
{id: 4, name: 'lol4'}
]);
};
testSaveOrder();
Shouldn't it simply follow the order as described by the comparator
function in the Backbone collection?