Skip to content

Instantly share code, notes, and snippets.

@gigafied
Created February 21, 2012 21:38
Show Gist options
  • Save gigafied/1879137 to your computer and use it in GitHub Desktop.
Save gigafied/1879137 to your computer and use it in GitHub Desktop.
Minion - Formats
minion.define("example.module", {
require : [
"f00.module.ModuleA",
"f00.module.ModuleB"
],
SomeModule : minion.extend("f00.module.BaseModule", {
init : function () {
this.__super();
this.moduleInstanceA = new this.__imports.ModuleA();
this.moduleInstanceB = new this.__imports.ModuleB();
}
})
});
minion.require(
[
"f00.module.ModuleA",
"f00.module.ModuleB"
],
function (ModuleA, ModuleB) {
minion.define("example.module", {
SomeModule : minion.extend("f00.module.BaseModule", {
init : function () {
this.sup();
this.moduleInstanceA = new ModuleA();
this.moduleInstanceB = new ModuleB();
}
})
});
}
);
minion.require(
[
"f00.module.BaseModule",
"f00.module.ModuleA",
"f00.module.ModuleB"
],
function (BaseModule, ModuleA, ModuleB) {
minion.define("example.module", {
SomeModule : BaseModule.extend({
init : function () {
this.sup();
this.moduleInstanceA = new ModuleA();
this.moduleInstanceB = new ModuleB();
}
})
});
});
define(
"example/module/SomeModule",
[
"f00/module/BaseModule",
"f00/module/ModuleA",
"f00/module/ModuleB"
],
function (BaseModule, ModuleA, ModuleB) {
return BaseModule.extend({
init : function () {
this.sup();
this.moduleInstanceA = new ModuleA();
this.moduleInstanceB = new ModuleB();
}
});
}
);
@gigafied
Copy link
Author

current.js is the currently supported syntax for a MinonJS Object, new1.js and new2.js are both supported formats in MinionJS 2.x, the main difference between the two is that new1.js uses minion.extend("f00.module.BaseModule") whereas new2.js specifies BaseModule as a requirement, and then calls BaseModule.extend({});

Also included is require.js which is an example of how we would do it using RequireJS. I actually like this approach for a number of reasons, though it does have a few shortcomings.

Please comment on which approach you prefer, then list any complaints, suggestions or comments you have regarding any of the approaches.

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