Last active
December 11, 2015 00:49
-
-
Save philmander/4519568 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
// Mixed.js | |
define(function() { | |
var Mixed = function(a, b) { | |
this.a = a; | |
this.b = b; | |
}; | |
Mixed.prototype.getA = function() { | |
return this.a; | |
}; | |
Mixed.prototype.getB = function() { | |
return this.b; | |
}; | |
return Mixed; | |
}); | |
// ToMix.js | |
define(function() { | |
var ToMix = function(x, y) { | |
this.x = x; | |
this.y = y; | |
}; | |
ToMix.prototype.getX = function() { | |
return this.x; | |
}; | |
ToMix.prototype.getY = function() { | |
return this.y; | |
}; | |
return ToMix; | |
}); |
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
define(function() { | |
return { | |
protos: { | |
mixed: { | |
module: "Mixed", | |
args: [ "A", "B" ], | |
//a list of proto references to mix | |
mixin: [ "toMix" ] | |
}, | |
toMix: { | |
module: "ToMix", | |
args: [ "X", "Y" ] | |
} | |
} | |
}; | |
}); |
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
// Inverted dynamically updates an instance of Mixed | |
// which effectively looks like this: | |
var Mixed = function(a, b) { | |
this.a = a; | |
this.b = b; | |
this.__toMix__; //is an instance of ToMix | |
}; | |
Mixed.prototype.getA = function() { | |
return this.a; | |
}; | |
Mixed.prototype.getB = function() { | |
return this.b; | |
}; | |
Mixed.prototype.getX = function() { | |
return this.__toMix__.getX(); | |
}; | |
Mixed.prototype.getY = function() { | |
return this.__toMix__.getY(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment