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
-
privateloggermmir.tools.Logger
-
- See:
-
private,constantMODEL_DEFAULT_NAMESPACE_NAMEString
-
Name of the default namespace (within the manager's space) into which Models will be loaded
-
private,constantMODEL_MANAGER_NAMESPACEObject
-
The "global" namespace for the model manager
-
privatemodelsMap
-
Map of models
Methods
-
private_init(initCallbackFunction, ctx){Promise}
-
This function invokes the method
mmir.ModelManager#foundModelsCallBack
to load all models in the path specified by *modelPath*.Name Type Description initCallbackFunction
function optional OPTIONAL The callback function from the constructor which shall be called after the initialization of the mmir.ModelManager
.ctx
Object optional OPTIONAL the context for the model implementations (DEFAULT: the global context, i.e. window) Returns:
Type Description Promise a 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 modelName
String Name of the model which should be returned Returns:
Type Description Object The model if found, null else -
privategetFullModelName(modelClassName){String}
-
This function returns the fully qualified model name (including namespace(s)).
Name Type Description modelClassName
String the model's class-name (i.e. without namespace) Returns:
Type Description String fully qualified name for the model -
privategetModelByName(fullModelName, ctx){Object}
-
This function returns the fully qualified model name (incl. namespace(s)).
Name Type Description fullModelName
String | 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 ctx
Object optional OPTIONAL the (base) context for the model implementations (DEFAULT: the global context MODEL_MANAGER_NAMESPACE) Returns:
Type Description Object the "raw" model object (may be a constructor or the main-singleton-namespace). Or null if there is no Model with the name. -
This function returns all loaded models.
Returns:
Type Description Array.<String> all loaded model names