Backbone.multi-extend
multiple inheritance,with super method call, for Backbone classes
Instalation
bower
$ bower i --save backbone.multi-extend
npm
$ npm i --save backbone.multi-extend
global
just checkout backbone.multi-extend.min.js
from this repo
Usage
CommonJs
var MultiExtend = require('backbone.multi-extend');
AMD
require(['backbone.multi-extend'], function(){
});
global
<script src="backbone.js"></script>
<script src="underscore.js"></script>
<script src="backbone.multi-extend.js"></script>
Example
var Mixin1 = {
initialize:function (){
this.inherited('initialize', arguments);
}
};
var Mixin2 = Backbone.Model.extend({
initialize:function (){
this.inherited('initialize', arguments);
}
});
var Mixin3 = {
initialize:function (){
this.inherited('initialize', arguments);
}
};
var NewModel = Backbone.Model.extend([{
initialize: function(){
this.inherited('initialize', arguments);
}
}, Mixin1, Mixin2, Mixin3]);
var newModel = new NewModel();
// invoke initialize method in next order
// NewModel.initialize()-->Mixin1.initialize()-->Mixin2.initialize()-->Mixin3.initialize()-->Backbone.Model.initialize()