Skip to content

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

@SpaceK33z

Description

@SpaceK33z

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions