Skip to content

Simple model object with minimalistic API to handle state and data changes

License

Notifications You must be signed in to change notification settings

romantaraban/tiny-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-model

Build Status

Simple module with minimalistic API. Allows to listen and get notified when state was changed.

#Usage

// create new instance of model
var test = new TinyModel({foo: 1, bar: 2});

// get value from model
var foo = test.get('foo');

// listen to changes in model
test.on('change:foo', function (eventName, propName, newValue) {
  console.log('Property ' + propName + 'was changed, new value: ' + newValue);
});

// set value in model
// this will change value of foo and trigger event 'change:foo'
test.set('foo', 3);

// remove property
// this also will trigger event 'remove:foo'
test.remove('foo');

About

Simple model object with minimalistic API to handle state and data changes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published