Options in Sub-Classes With Mixins Still Works!
By Ryan Florence, published 2010-04-27
Part of the issue Migrated Articles From Original Site Structure..
When Extending and Implementing classes, you can have options specific to each class and they will all be merged nicely together in the final class.
var Human = new Class({
Implements: [Options,Events],
options: {
name: 'Unknown'
},
initialize: function(options){
this.setOptions(options);
}
});
var Warrior = new Class({
options: {
clan: 'Wildcats',
killcount: 0
}
});
var Ninja = new Class({
Extends: Human,
Implements: Warrior,
options: {
side: 'evil'
}
});
var ryu = new Ninja({
name: 'Ryu Hayabusa',
side: 'good',
killcount: 1
});
// all of our options from the three classes as merged
console.log(ryu.options);