Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to save the order of entities when merging new models #9

Open
somebody32 opened this issue Feb 10, 2016 · 1 comment
Open

Try to save the order of entities when merging new models #9

somebody32 opened this issue Feb 10, 2016 · 1 comment

Comments

@somebody32
Copy link
Contributor

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();
@Robinfr
Copy link

Robinfr commented Apr 29, 2016

Shouldn't it simply follow the order as described by the comparator function in the Backbone collection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants