Last active
August 29, 2015 14:08
-
-
Save michalkowol/4191620b733f0cbeb3ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mtv = (function (mtv) { | |
'use strict'; | |
mtv.TraitA = function (self) { | |
self.functionA = function () { | |
console.log('[start]: TraitA.functionA'); | |
console.log(self.getModel()); | |
console.log('[end]: TraitA.functionA'); | |
}; | |
self.dummyModel = function () { | |
console.log('[start]: TraitA.dummyModel'); | |
console.log('[end]: TraitA.dummyModel'); | |
}; | |
}; | |
mtv.TraitB = function (self) { | |
self.functionB = function () { | |
console.log('[start]: TraitB.functionB'); | |
console.log(self.getModel()); | |
console.log('[end]: TraitB.functionB'); | |
}; | |
self.dummyModel = function () { | |
console.log('[start]: TraitB.dummyModel'); | |
console.log('[end]: TraitB.dummyModel'); | |
}; | |
self.onlyB = function () { | |
console.log('[start]: TraitB.onlyB'); | |
console.log('[end]: TraitB.onlyB'); | |
}; | |
}; | |
mtv.classWithTraitATraitB = function (model) { | |
var self = _with(mtv.TraitA, mtv.TraitB); | |
self.getModel = function () { | |
console.log('[start]: classWithTraitATraitB.getModel'); | |
console.log('[end]: classWithTraitATraitB.getModel'); | |
return model; | |
}; | |
self.functionB = function () { | |
console.log('[start]: classWithTraitATraitB.functionB'); | |
self.super.functionB(); | |
self.functionA(); | |
console.log('[end]: classWithTraitATraitB.functionB'); | |
}; | |
return self; | |
}; | |
var classA = mtv.classWithTraitATraitB('model'); | |
classA.functionA(); | |
classA.functionB(); | |
classA.dummyModel(); | |
return mtv; | |
})(mtv || {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment