When resetting parent (during a subset reset), don't remove the subset's models from the parent. #3

Merged
merged 1 commit into from Feb 13, 2012

Conversation

Projects
None yet
2 participants
Collaborator

saimonmoore commented Feb 10, 2012

The idea being that though these models may not belong to this
particular subset any longer, they may still belong to another subset.
The parent should always contain the superset of models.

So when resetting the parent, we look for any models from the new set of
models that are missing from the parent and include them.

Additionally, when adding a model to a subset's own collection we try
and look it up on the parent (so both collections reflect the same
instance) and failing that we create a new model instance (if only
attributes were added).

Updated tests to reflect the multiple subset use case.

Note: To avoid the parent's reset event from re-resetting the subset's
collection, we mark the event with a 'subset_reset' option. We only act
on proxied 'reset' events that don't have this marker. This has the
additional benefit of not propagating the parent's (subset initiated) reset event to
sibling subsets.

@saimonmoore saimonmoore When resetting parent (during a subset reset), don't remove the subse…
…t's models from the parent.

The idea being that though these models may not belong to this
particular subset any longer, they may still belong to another subset.
The parent should always contain the superset of models.

So when resetting the parent, we look for any models from the new set of
models that are missing from the parent and include them.

Additionally, when adding a model to a subset's own collection we try
and look it up on the parent (so both collections reflect the same
instance) and failing that we create a new model instance (if only
attributes were added).

Updated tests to reflect the multiple subset use case.

Note: To avoid the parent's reset event from re-resetting the subset's
collection, we mark the event with a 'subset_reset' option. We only act
on proxied 'reset' events that don't have this marker. This has the
additional benefit of not propagating the parent's (subset initiated) reset event to
sibling subsets.
543059d

masylum was assigned Feb 10, 2012

Collaborator

saimonmoore commented Feb 10, 2012

Tests pass by the way...

Owner

masylum commented on test/test.js in 543059d Feb 11, 2012

of course they pass! :)

Owner

masylum commented on 543059d Feb 11, 2012

looks good. I should review it twice to be sure to understand how does it work

@masylum masylum added a commit that referenced this pull request Feb 13, 2012

@masylum masylum Merge pull request #3 from masylum/dont_touch_parent
When resetting parent (during a subset reset), don't remove the subset's models from the parent.
8203776

@masylum masylum merged commit 8203776 into master Feb 13, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment