Return to Snippet

Revision: 28927
at July 17, 2010 07:14 by zwigby


Updated Code
package
{
  [Bindable]
  public class MainModel
  {
    private static var _instance:MainModel = new MainModel(ModelEnforcer);
    
    public static function getInstance():MainModel
    {
      return _instance;
    }
    
    public function MainModel(enforcer:Class)
    {
      if(enforcer != ModelEnforcer) {
        throw new Error("Use MainModel.getInstance to access model");
      }
    }
 
  }
}

class ModelEnforcer {}

Revision: 28926
at July 16, 2010 06:28 by zwigby


Initial Code
package
{
  import mx.collections.ArrayCollection;
  
  [Bindable]
  public class MainModel
  {
    private static var _instance:MainModel = new MainModel(ModelEnforcer);
    
    public static function getInstance():MainModel
    {
      return _instance;
    }
    
    public function MainModel(enforcer:Class)
    {
      if(enforcer != ModelEnforcer) {
        throw new Error("Use MainModel.getInstance to access model");
      }
    }
 
  }
}

class ModelEnforcer {}

Initial URL

                                

Initial Description

                                

Initial Title
Flex Model Singleton

Initial Tags

                                

Initial Language
ActionScript