klass icon indicating copy to clipboard operation
klass copied to clipboard

Mixin calling its own thing instead of super's thing

Open bcowgill opened this issue 10 years ago • 0 comments

I was looking at how the mixin code works. In the test case paraphrased below, If I wanted to implement a mixin where I called the Sub-class's thing before the implemented thing, how do you do that? Calling this.thing directly will just give an infinite loop.

test('should implement a wrapper method for mixins', 5, function () { ... inst.implement({ thing: function (n) { console.log('Implement#thing()'); ok(true, 'called implementer'); //this.supr(); would be called by subclass' thing, if we could this.thing(); // WARNING infinite loop. want to call the Sub's thing, not the base thing // this.myself(); would be a good expression for that this.boooshr(); }, boooshr: function () { console.log('Implement#boooshr()'); ok(true, 'called boooshr'); } }).thing();

bcowgill avatar Feb 04 '15 21:02 bcowgill