Skip to content

oscarmorrison/oModel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oModel

oModel is a work in progress, with no public release yet.

Goal

Build a super simple js model that allows for onChange call backs.

Insperation

Installation

TBD bower and npm dependency

  • compatible as client or node dependancy

API Docs

Create a new model (without any attributes)

var person = new Model();

or with attributes / properties

var person = new Model({
    name: 'oscar'
});

Set / Update attributes

person.set('age', 25);

...or multiple at once

person.update({
    name: 'george',
    age: 20
});

update is an alias for set

Listen to models

var callback = function(attributes) {
    console.log(attributes);
}
person.onChange(callback);

OnChange

person.update('name', 'edward');

// callback log
// {name: 'edward', age: 20}

Stop listening to models for callback

person.off(callback)

Stop listening to models all

person.off()

About

Simplest JS Model with listeners

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors