-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow multiple instantiation of RelationalModels with the same typ…
…e and `id`. This ensures (at least) deterministic behavior. Fixes #180. This commit also includes a bit of cleanup in the override for `Backbone.Collection.prototype.add`.
- Loading branch information
1 parent
4e6da75
commit 351053c
Showing
2 changed files
with
74 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
351053c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about cases when you'd intentionally want another instance of a model with the same data as one that's already registered? There needs to be an option to disable registering it. There are a number of reasons to want to have copies of models.
Use case: A model has data we sometimes don't want to save to the server but still want available to toJSON(). The only graceful way to handle this is to create a new model with the same data (and ID), remove the unwanted data, then save.
351053c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, moreover, cases where
Collection.reset
are used seem to trigger this error.