Immutable Collections and Models for Backbone.js. Freeze is designed to hold collections/models that will never change during the lifespan of your JS.
Freeze follows the principle of Fail Loudly; when you attempt to modify a collection or model it will throw an error.
Freeze is available on npm bower as "backbone.freeze"
bower install backbone.freeze OR npm install backbone.freeze
// List of usable countries should never changevar usableCountries =id: 1 name: "United States"id: 2 name: "Canada"id: 3 name: "England";var usableCountriesImmutable = usableCountries;usableCountriesImmutable; // This will throw an error!
// The description of a rectangle should never change after construction, or that would make area incorrect// TODO - make area calculate on changevar rectangle =color: "red"width: 7height: 5area: 35;rectangle; // This will throw an error!
- Backbone 1.0.0 - 1.1.2
- Underscore 1.4.4 - 1.7.0