ObjectFactory Class
Internal class designed to create ludoJS class instances. The global ludo.factory is an instance of this class
Item Index
Methods
create
-
config
Creates an instance of a class by "type" attribute
Parameters:
-
config
Object | ludo.Core
Returns:
ludo.factory.createNamespace
-
ns
Method used to create global name space for your web applications. This methods makes ludoJS aware of the namespace and register a global variable window[ns] for it if it does not exists. It makes it possible for ludoJS to find classes by type attribute.
Parameters:
-
ns
String
Example:
ludo.factory.createNamespace('MyApp');
...
...
MyApp.MyClass = new Class({
Extends: ludo.View,
type : 'MyApp.MyClass'
});
var view = new ludo.View({
children:[{
type : 'MyApp.MyClass'
}]
});
Notice that "Namespace" is used as prefix in type attribute in the last snippet. For standard ludoJS components, you could write type:"View". For views in your namespaces, you should always use the syntax "Namespace.ClassName"
registerClass
-
typeName
-
classReference
Register a class for quick lookup. First argument is the value of the type attribute you want to support. It is not required to call this for each class you create. The alternative is to register a namespace by calling ludo.factory.registerNamespace('MyApp'). However, if you have a lot of classes, it will increase performance by registering your classes. ludoJS will then know it instantly and doesn't have to traverse the name space tree to find it.
Parameters:
-
typeName
String -
classReference
ludo.Core
Example:
ludo.factory.createNamespace('MyApp');
MyApp.MyView = new Class({
Extends: ludo.View,
type: 'MyApp.MyView'
});
ludo.factory.register('MyApp.MyView', MyApp.MyView);
...
...
new ludo.View({
...
children:[{
type:'MyApp.MyView' // ludoJS now knows how to find this class
}]
});