Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active December 11, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philmander/4518684 to your computer and use it in GitHub Desktop.
Save philmander/4518684 to your computer and use it in GitHub Desktop.
//app-config.js
define(function() {
return {
protos: {
movieLister: {
module: "movies/movie-lister",
args: [
"*movieFinder"
]
mixin: {
ref: "movieViewer",
override: false
}
},
movieViewer: {
module: "movie/movie-"
}
}
};
});
//mixin function
var mixin = function(toMix, mixWith, toMixId, override) {
override = typeof override === "boolean" ? override : true;
for(var fn in mixWith) {
if(typeof mixWith[fn] === "function" &&
(!(fn in toMix) || (fn in toMix && override))) {
(function(fn) {
toMix[fn] = function() {
return mixWith[fn].apply(mixWith, arguments);
};
})(fn);
}
}
toMix["__" + toMixId + "__"] = mixWith;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment