0.2.8 • Published 11 years ago
Neuro v0.2.8
Neuro
A MooTools client-side MVC.
Version: 0.1.0 (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
// Set the default data
_data: {
firstName: ''
,lastName: ''
,hp: 10
,max: 100
,lvl: 1
// You can set a function as a custom getter. "this" will be _data, not the model itself.
,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'); // 'Bruce Lee'
bruceLee.get('lvl'); // 99
bruceLee.set('lvl', 100).get('lvl'); // 100
Collection
Subclass Collection with MooTools Class.
var Humans = new Class({
Extends: Neuro.Collection
,Model: HumanModel
});
Add data to the collection
// Add one dataset to the collection
Humans.add({
firstName: 'Chuck'
,lastName: 'Norris'
,hp: 1000
});
// Add multiple datasets to the collection
Humans.add({
firstName: 'Kareem Abdul'
,lastName: 'Jabbar'
,hp: 1000
,lvl: 80
}, {
firstName: 'Gary'
,lastName: 'Elms'
,hp: 800
,lvl: 81
});
// Add a model instance
Humans.add(bruceLee);
Get a model from the collection by index
Humans.get(4); // bruceLee model
Remove a model from the collection
var garyElms = Humans.get(3); // Gary Elms model
Humans.remove(garyElms);
// Check if the removed model still exists in the collection
Humans.hasModel(garyElms); // false
ToDo
- Add a builder
- Add a Router mechanism
- Add a Sync mechanism
0.2.8
11 years ago
0.2.7
12 years ago
0.2.6
12 years ago
0.2.5
12 years ago
0.2.4
12 years ago
0.2.3
12 years ago
0.2.2
12 years ago
0.2.1
12 years ago
0.2.0
12 years ago
0.1.9
12 years ago
0.1.8
12 years ago
0.1.7
12 years ago
0.1.6
12 years ago
0.1.5
12 years ago
0.1.4
12 years ago
0.1.3
12 years ago
0.1.2
12 years ago
0.1.1
12 years ago
0.1.0
12 years ago