gigafied / minion Goto Github PK
View Code? Open in Web Editor NEWClassical Inheritance for JavaScript
Classical Inheritance for JavaScript
If I define a Class like
minion.define("core.facade", {
require : [
"core.control.Controller",
"core.model.Model",
"core.view.View",
],
Facade : minion.extend("minion.Singleton", {
})
and then create a subclass of Facade, I have to repeat the require statement:
minion.define("application.facade", {
require : [
"core.control.Controller",
"core.model.Model",
"core.view.View",
],
ApplicationFacade : minion.extend("core.facade.Facade", {
})
Is this correct? My expectation was that I wouldn't have to repeat the require statement.
Peter
From the HTML wrapper, I need access to some methods in some of my own classes (instances in an already bootstrapped application) that extend minion.class or minion.singleton. What is the best way to accomplish this?
I was thinking I should use minion.get but all I'm getting is:
Uncaught TypeError: Object function ()
{
if (arguments[0] !== "no_init")
{
/*
Handy for referencing dependencies. If a Class requires example.Test, then you can reference said class
in any method by this.__imports.Test;
*/
if (!_class.prototype.hasOwnProperty("__imports"))
{
_class.prototype.__imports = minion.use(this.__dependencies, {});
}
if (!this.__preInit)
{
for (var attr in _perInstanceProps)
{
if (_perInstanceProps.hasOwnProperty(attr))
{
this[attr] = _copyTo({}, _perInstanceProps[attr]);
}
}
// All real construction is actually done in the init method
return this.init.apply(this, arguments);
}
else
{
return this.__preInit.apply(this, arguments);
}
}
} has no method 'getProxyName'
If I have a class like:
minion.define("core.command", {
SGSimpleCommand : minion.extend("core.observer.SGEventDispatcher", {
execute : function ()
{
throw new Error("Override execute in your subclass");
}
})
});
And I extend this class:
minion.define("application.control", {
PrepareViewCommand : minion.extend("core.command.SGSimpleCommand", {
require : [
"application.view.components.ViewComponent"
],
execute : function (event)
{
var el = document.getElementById(event.body);
el.appendChild(new this.__imports.ViewComponent());
}
})
});
then the require doesn't seem to work in the subclass as new this.__imports.ViewComponent() turns up as undefined. I can only get it to work if I use:
minion.define("application.control", {
PrepareViewCommand : minion.extend("core.command.SGSimpleCommand", {
execute : function (event)
{
var el = document.getElementById(event.body);
minion.require(["application.view.components.ViewComponent"], function (ViewComponent)
{
el.appendChild(new ViewComponent());
});
}
})
})
Is this expected behaviour?
__preDefine hook to add dynamic properties/methods to a class after it is defined.
__preDefine : function () {
for(var f in this.fields) {
// Do something cool here...
}
}
This will allow you to modify a Class after all it's dependencies are loaded and after all other properties are set.
Provide a way to map an entire namespace to a separate class path:
minion.provides("namespace.*", "path/to/namespace/js/");
I want to define application constants (to avoid using strings for events all over the place) and am using the __static object. But, it seems that I cannot use these static properties in the class where I've defined the __static object?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.