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

Think about existing-model-in-store handling #4

Closed
SpaceK33z opened this issue Feb 13, 2017 · 1 comment
Closed

Think about existing-model-in-store handling #4

SpaceK33z opened this issue Feb 13, 2017 · 1 comment

Comments

@SpaceK33z
Copy link
Contributor

SpaceK33z commented Feb 13, 2017

In Backbone, when you do this:

const model = new Backbone.Model();
const collection = new Backbone.Collection.extend({ model: model });

collection.add({ id: 1, foo: false });
// do some other stuff
collection.add({ id: 1, foo: true });

// Final result: [{ id: 1, foo: true }]

It will only add a model to the collection once and override its values. Currently mobx-binder will not do that, it would just add the same model twice.

I'm not sure yet if we should build this into mobx-binder. It can be very nice, but it can also be weird black magic.

Maybe specifically for .add() it make sense, but for .fetch() I'd rather do a full reset of the store each time. In most of our Backbone apps we now do collection.fetch({ reset: true }) nearly everywhere, so we could make that the default here.

Needs discussion with @jasperstam and @abzainuddin.

@SpaceK33z
Copy link
Contributor Author

Discussed this with Burhan, we should throw an error if .add() tries to add a model to the store that already exists with that id.

stefanmajoor pushed a commit that referenced this issue Jun 30, 2021
Proper way of adding header to model validation request
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

1 participant