1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- "use strict";
- cc._RF.push(module, '70817qeF59MOqhgJXMr++vR', 'ModelManager');
- // lightMVC/core/manager/ModelManager.ts
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var ModelManager = /** @class */ (function () {
- /**
- * @constructor
- * @private
- */
- function ModelManager() {
- this._modelList = {};
- }
- /**
- * 单例获取类
- */
- ModelManager.getInstance = function () {
- return this._instance;
- };
- /**
- * 获取model对象
- * @param {{new (): BaseModel}} model
- */
- ModelManager.prototype.getModel = function (model) {
- var key = cc.js.getClassName(model);
- return this._modelList[key];
- };
- /**
- * 注册数据model
- * @param {{new (): BaseModel}} model
- */
- ModelManager.prototype.registerModel = function (model) {
- var key = cc.js.getClassName(model);
- if (this._modelList.hasOwnProperty(key)) {
- console.log(key, "已经存在,不可重复注册!");
- }
- else {
- var m = new model();
- m.init();
- this._modelList[key] = m;
- }
- };
- /**
- * 移除注册
- * @param {{new (): BaseModel}} model
- */
- ModelManager.prototype.unregisterModel = function (model) {
- var key = cc.js.getClassName(model);
- if (this._modelList.hasOwnProperty(key)) {
- var m = this._modelList[key];
- m.clear();
- delete this._modelList[key];
- }
- else {
- console.warn(key, "不存在!");
- }
- };
- /**
- * 释放并移除所有model
- */
- ModelManager.prototype.removeAllModel = function () {
- // 释放并移除所有model
- for (var key in this._modelList) {
- var model = this._modelList[key];
- model.clear();
- delete this._modelList[key];
- }
- this._modelList = {};
- };
- /** 实例 */
- ModelManager._instance = new ModelManager();
- return ModelManager;
- }());
- exports.default = ModelManager;
- cc._RF.pop();
|