Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active December 10, 2015 10:59
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/4424503 to your computer and use it in GitHub Desktop.
Save philmander/4424503 to your computer and use it in GitHub Desktop.
Reference Inverted application config object.
var applicationConfig = {
// a map of 'protos', inverted objects
protos: {
//the unique id of a proto
protoId: {
//the amd or common js module name which exports the proto
module: "moduleName",
//contructor arguments to inject into protos with prototype or singleton scope
args: [
//a literal value argument
"string|number|boolean|object",
//a map of literal values or dependencies
{
option1: "value1",
option2: "value2",
option3: "*value3"
},
//a dependency referencing another proto id, using shorthand asterisk notation to imply a dependency
//interfaces are optional
"*dependencyProtoId [interfaceId, interfaceId...]",
//a dependency using longhand notation, interface can also be added here
{
ref: "dependencyProtoId"
},
//an arugment generated by a factory method
{
factoryRef: "dependencyProtoId",
factoryMethod: "dependencyMethodName"
}
],
//property and/or method names and values to inject, the rules for constructor arguments are similar
props: {
propName: "string|number|boolean|object",
methodName: "string|number|boolean|object",
},
//a reference to a prototype to add to this proto's prototype chain
extendsRef: "extendingProtoId",
//a list of references to other protos to mixin
mixin:
[ "mixinProtoId", "anotherProtoId", {
//longhand mixin notation that includes an option to override
ref: "anotherProtoId",
override: false //defaults to true
}]
}
//the scope of this proto
scope: "prototype|singleton|static",
//overrides the global injectAppContext setting
injectAppContext: true|false
},
anotherProtoId: {
module: "moduleName"
}
},
interfaces: {
interfaceId: "methodName, methodName...",
anotherIntefaceId: "methodName, methodName..."
}
//specifies if the appContext instance should be injected into all instantiated protos as the property __appContext__
//defaults to false
injectAppContext: true|false
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment