Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Mixins for can.Construct classes

$
0
0
Hello!

What's the proper way to implement mixins for can.Construct classes? I'd like to mixin methods into different classes, extended from can.Construct (to have something like multiple inheritance).

Should it be done something like:

var MyClass1 = can.Construct.extend({
      ....
});

var MyClass2 = can.Construct.extend({
      ....
});

var mixin = {
      myMethod = function () {...}
}

can.extend(MyClass1.prototype, mixin);
can.extend(MyClass2.prototype, mixin);

Is it correct code snippet? Or there is another, more proper way to do it?

Viewing all articles
Browse latest Browse all 3491

Trending Articles