0.1.11 • Published 9 years ago

backbone.freeze v0.1.11

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Build Status

backbone.freeze

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.

#Installing

Freeze is available on npm bower as "backbone.freeze"

bower install backbone.freeze

OR

npm install backbone.freeze

#Examples Freeze.Collection:

// List of usable countries should never change
var usableCountries = [
    { id: 1, name: "United States" },
    { id: 2, name: "Canada" },
    { id: 3, name: "England" }
];
var usableCountriesImmutable = new Backbone.Freeze.Collection(usableCountries);

usableCountriesImmutable.add({ id: 4, name: "Mexico"}); // This will throw an error!

Freeze.Model:

// The description of a rectangle should never change after construction, or that would make area incorrect 
// TODO - make area calculate on change
var rectangle = new Backbone.Freeze.Model({
    color: "red",
    width: 7,
    height: 5,
    area: 35
});

rectangle.set('height', 10); // This will throw an error!

#Requirements

  • Backbone 1.0.0 - 1.1.2
  • Underscore 1.4.4 - 1.7.0
0.1.11

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago