0.5.1 • Published 10 years ago

obs-model v0.5.1

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

Synopsis

obs-model provides a minimal baseline for defining MVC or MVVM models with observable attributes.

Basic usage example

var User = model('User')
    .attr('id')
    .attr('username');

var bob = new User({id: 1, username: 'bob'});

bob.username.subscribe(function(value) {
    console.log("Bob's username is now: " + value);
});

bob.username('admin');
// -> "Bob's username is now: admin"

API

model(name)

Create a Model with the given name.

Model.modelName

The model's name as passed to model().

Model.attr(name, options)

Defines a new attribute with the given name. The options can be an object containing configuration data for model plugins.

The attribute will appear as an observable property on new model instances.

Model.use(plugin:Function)

Adds the given plugin to the model. The function will later be called by the model's constructor with this set to the new model instance.

This method is the backbone of model extensibility.

Model#model

The Model this model is an instance of.

Model#dismiss()

Runs the model's destructors. Plugins can use these to free event listeners, subscriptions and such.

License

The MIT/Expat license.

0.5.1

10 years ago

0.5.0

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago