"use strict";
import { Utils } from '../utils';
/* SOURCE-CODE-START */
/**
* 视图作用域管理器
* @class
*/
function ViewScopeManager() {
//
}
ViewScopeManager.viewScopes = {};
/**
* @description 返回指定的视图作用域
* @param {string} viewName 视图名
* @param {boolean} [allowCreate=true]
* @returns {object}
*/
ViewScopeManager.getViewScope = function (viewName, allowCreate) {
if (!Utils.isString(viewName)) {
throw new Error('argument#0 "viewName" required string');
}
allowCreate = !(allowCreate === false);
var viewScope = ViewScopeManager.viewScopes[viewName];
if (Utils.isNullOrUndefined(viewScope) && allowCreate) {
viewScope = {};
ViewScopeManager.viewScopes[viewName] = viewScope;
}
return viewScope;
};
/**
* @description 设置指定的视图作用域
* @param {string} viewName 视图名
* @param {object} viewScope
*/
ViewScopeManager.setViewScope = function (viewName, viewScope) {
if (!Utils.isString(viewName)) {
throw new Error('argument#0 "viewName" required string');
}
ViewScopeManager.viewScopes[viewName] = viewScope;
};
/**
* @description 移除指定的视图作用域
* @param {string} viewName 视图名
*/
ViewScopeManager.removeViewScope = function (viewName) {
if (!Utils.isString(viewName)) {
throw new Error('argument#0 "viewName" required string');
}
delete ViewScopeManager.viewScopes[viewName];
};
/* SOURCE-CODE-END */
export { ViewScopeManager };