GitXplorerGitXplorer
t

model

public
0 stars
0 forks
2 issues

Commits

List of commits on branch master.
Unverified
98582ed4e3537bf2f7453fd895eec3208e856afd

Deprecate in favour of timoxley/react

ttimoxley committed 12 years ago
Unverified
fb88de408038422ee9faa1b06bf2ddd82a56f04c

Update docs with mixin info.

ttimoxley committed 12 years ago
Unverified
fab2c951f653146db07e5269a7031b7aa83adba6

Release 0.0.2

ttimoxley committed 12 years ago
Unverified
bcfbf8851c4d91c71b7bd69508e719aa27d81555

Allow use as a mixin.

ttimoxley committed 12 years ago
Unverified
cc7ae75dd6c11c458e066cd6bd105e0defe2fd20

Docs and tidy up.

ttimoxley committed 12 years ago
Unverified
3ea77c9e02516a5009e984160bb31d5280ef8636

Initial commit

ttimoxley committed 12 years ago

README

The README file for this repository.

model

Simple Data Models

DEPRECATED

See timoxley/react for a cleaner solution without all this get/set nonsense.

Installation

$ component install timoxley/model

API

Model()

Initialize a new Model with data properties, or use as a mixin.

var Model = require('model')

var user = new Model({
  name: 'Tim',
  age: 27
})

// or as a mixin:

var User = function(data) {
  this.set('name', data.name)
  this.set('age', data.age)
}

Model(User.prototype)

Model#get(name:String)

Get the value of Model property specified by name or if name is not supplied, return the whole current model.

var model = new Model({
  name: 'Tim'
})
model.get('name') //=> 'Tim'

Model#set(name:String)

Set a property specified by name to value or if supplied an Object, add or update properties on the model, as specified by the given Object.

Will trigger change events on the model if the model changes.

var model = new Model({
  name: 'Tim'
})

model.set('name', 'Tim Oxley')

model.set({
  age: 27
)

model.get('name') //=> 'Tim Oxley'
model.get('age') //=> 27

License

MIT