Skip to content

Instantly share code, notes, and snippets.

@lazd
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save lazd/30c3a17fed9db5980080 to your computer and use it in GitHub Desktop.

Select an option

Save lazd/30c3a17fed9db5980080 to your computer and use it in GitHub Desktop.
Mixin Question
// Define a class
var A = Class({
toString: 'A',
// Define a method
method: function() {
return 'ClassA';
}
});
// Extend A
var B = A.extend({
toString: 'B',
// Add mixins to the prototype
mixins: [
{
method: function() {
return 'Mix1'+this._super();
}
},
{
method: function() {
return 'Mix2'+this._super();
}
}
],
// Override a method
method: function() {
return 'ClassB'+this._super();
}
});
var b = new B();
// Add mixins to the instance
b.mixin({
method: function() {
return 'Mix4'+this._super();
}
});
// Call a method
b.method();
@lazd
Copy link
Author

lazd commented May 19, 2014

What do you expect b.method() to return?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment