
Untitled
By: a guest on
May 9th, 2012 | syntax:
None | size: 0.82 KB | hits: 13 | expires: Never
App.loadObject = function(type, name, params) {
if(App[type] == null) {
Ti.API.warn('Trying to load an object that does not exist in the App namespace');
return false;
} else if(App[type][name] == null) {
// If the name of the type object doesn't exist
Ti.include(type.toLowerCase() + '/' + name.toLowerCase() + '.js');
Ti.API.info(type + ' ' + name + ' Loaded');
return new App[type][name](params);
} else {
// If the name of the type object has already been loaded / exists
Ti.API.info(type + ' ' + name + ' Loaded');
return new App[type][name](params);
}
};
/** Used in app **/
// This will amount to 'new App.Controllers.List({ type: 'tasks', somearg: true });'
var someThing = App.loadObject('Controllers', 'List', { type: 'task', somearg: true });