Model Class
A PureMVC MultiCore IModel implementation.
In PureMVC, IModel implementors provide access to IProxy objects by named lookup.
An IModel assumes these responsibilities:
- Maintain a cache of IProxy instances.
- Provide methods for registering, retrieving, and removing IProxy instances.
Your application must register IProxy instances with the IModel. Typically, you use an ICommand to create and register IProxy instances once the IFacade has initialized the core actors.
Implements
Constructors
Code new Model(String key) #
Constructor.
This IModel implementation is a Multiton, so you should not call the constructor directly, but instead call the static getInstance method.
- Throws MultitonErrorModelExists if instance for this Multiton key instance has already been constructed.
Model( String key ) { if ( instanceMap[ key ] != null ) throw new MultitonErrorModelExists(); multitonKey = key; instanceMap[ multitonKey ] = this; proxyMap = new Map<String,IProxy>(); initializeModel(); }
Static Methods
Code IModel getInstance(String key) #
IModel Multiton Factory method.
- Returns the IModel Multiton instance for the specified key.
static IModel getInstance( String key ) { if ( key == null || key == "" ) return null; if ( instanceMap == null ) instanceMap = new Map<String,IModel>(); if ( instanceMap[ key ] == null ) instanceMap[ key ] = new Model( key ); return instanceMap[ key ]; }
Static Fields
Methods
Code void initializeModel() #
Initialize the IModel instance.
Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.
void initializeModel( ){ }
Code IProxy removeProxy(String proxyName) #
Remove an IProxy instance from the IModel.
- Param proxyName - name of the IProxy instance to be removed.
- Returns IProxy - the IProxy that was removed from the IModel.
IProxy removeProxy( String proxyName ) { IProxy proxy = proxyMap[ proxyName ]; if ( proxy != null ) { proxyMap[ proxyName ] = null; proxy.onRemove(); } return proxy; }