arturadib / agility

Javascript MVC for the "write less, do more" programmer
http://agilityjs.com
MIT License
542 stars 70 forks source link

model methods #83

Open weepy opened 12 years ago

weepy commented 12 years ago

is it possible to have methods on a model ?

I thought also it might be useful to add binding such that if the return type is a function - then it is called before being used.

so we could have :

model : {
  first: 'John',
  second: 'Smith',
  fullName: function() {
    return this.first() + ' ' + this.second()
  }
}

does this fit into the framework ?

phonovision commented 12 years ago

Sometimes it is uesful to just get the function and not the result of the function, for example for some sort of state machine.

But you can explicity call the funtion like this: someObject.model.get('fullName')();