new mmir.ModelManager()
A class for managing the models of the application (MVC-Component).
It's purpose is to load the models automatically. This "class" is a singleton - so that only one instance is in use.
TODO add example for usage (models as "class" / models as "singleton")
It's purpose is to load the models automatically. This "class" is a singleton - so that only one instance is in use.
TODO add example for usage (models as "class" / models as "singleton")
Members
-
private,constantGLOBAL_NAMESPACEObject
-
The global namespace
-
privateloggerLogger
-
- See:
-
private,constantMODEL_DEFAULT_NAMESPACE_NAMEString
-
Name of the default namespace (within the global space) into which Models will be loaded
-
privatemodelsDictionary
-
Array of models
Methods
-
private_init(initCallbackFunction, ctx){Promise}
-
This function invokes the method
mmir.ModelManager#foundModelsCallBackto load all models in the path specified by *modelPath*.Name Type Description initCallbackFunctionfunction optional OPTIONAL The callback function from the constructor which shall be called after the initialization of the mmir.ModelManager.ctxObject optional OPTIONAL the context for the model implementations (DEFAULT: the global context, i.e. window) Returns:
deferred promise that gets fulfilled when models are loaded.
-
privatedoGetModelInstance()
-
Returns the instance for a model implementation: If the model-object is a constructor (i.e. a function), a new instance is created and returned. Otherwise the model-object itself is returned (e.g. for singleton pattern models).
-
get(modelName){Object}
-
This function gets the model by name.
Name Type Description modelNameString Name of the model which should be returned Returns:
model if found, null else
-
privategetFullModelName(modelClassName){String}
-
This function returns the fully qualified model name (including namespace(s)).
Name Type Description modelClassNameString the model's class-name (i.e. without namespace) Returns:
qualified name for the model
-
privategetModelByName(fullModelName, ctx){Object}
-
This function returns the fully qualified model name (incl. namespace(s)).
Name Type Description fullModelNameString | Array.<String> the fully qualified model name (i.e. with namespace(s)) Note, if {String} components/namespaces are separated by a . (dot) If {Array } the entries correspond to the namespace components (without dots), where the last entry corresponds to the class/singleton name ctxObject optional OPTIONAL the (base) context for the model implementations (DEFAULT: the global context GLOBAL_NAMESPACE) Returns:
"raw" model object (may be a constructor or the main-singleton-namespace). Or null if there is no Model with the name.
-
getModelNames(){Array.<String>}
-
This function returns all loaded models.
Returns:
loaded model names