Marker interface used to mark the custom ModelLocator.
IModelLocator is the marker interface used by Cairngorm applications to implement the model in an Model-View-Controller architecture.
The model locator in an application is a singleton that the application uses to store the client side model. An example implementation might be:
class ShopModelLocator implements IModelLocator {
private static var instance:ShopModelLocator;
public function new() {
if (instance != null) {
throw new CairngormError(
CairngormMessageCodes.SINGLETON_EXCEPTION, "ShopModelLocator");
}
instance = this;
}
public static function getInstance():ShopModelLocator {
if (instance == null) {
instance = new ShopModelLocator();
}
return instance;
}
public var products:ICollectionView;
}
Throughout the rest of the application, the developer can then access the products from the model, as follows:
var products:ICollectionView = ShopModelLocator.getInstance().products;