Neuro
A MooTools client-side MVC.
Version: 0.1.3 (Alpha)
Influences:
Dependencies:
Focus:
- uncoupled coding but allow for a coupled organization if necessary
- provide base for applications
Usage
Model
Subclass Model with MooTools Class.
var HumanModel = new Class({
Extends: Neuro.Model
_data: {
firstName: ''
,lastName: ''
,hp: 10
,max: 100
,lvl: 1
,name: function(){
return this.firstName + ' ' + this.lastName;
}
}
});
Create a model instance
var bruceLee = new HumanModel({
firstName: 'Bruce'
,lastName: 'Lee'
,hp: 1000
,lvl: 99
});
bruceLee.get('name');
bruceLee.get('lvl');
bruceLee.set('lvl', 100).get('lvl');
Collection
Subclass Collection with MooTools Class.
var Humans = new Class({
Extends: Neuro.Collection
,Model: HumanModel
});
Add data to the collection
Humans.add({
firstName: 'Chuck'
,lastName: 'Norris'
,hp: 1000
});
Humans.add({
firstName: 'Kareem Abdul'
,lastName: 'Jabbar'
,hp: 1000
,lvl: 80
}, {
firstName: 'Gary'
,lastName: 'Elms'
,hp: 800
,lvl: 81
});
Humans.add(bruceLee);
Get a model from the collection by index
Humans.get(4);
Remove a model from the collection
var garyElms = Humans.get(3);
Humans.remove(garyElms);
Humans.hasModel(garyElms);
ToDo
- Add a builder
- Add a Router mechanism
- Add a Sync mechanism