2016-02-17 20:44:40 +00:00
|
|
|
/// <reference path="typings/main.d.ts" />
|
|
|
|
import plugins = require("./smartenv.plugins");
|
2016-02-23 14:03:14 +00:00
|
|
|
var beautylog = require("beautylog");
|
2016-02-17 20:44:40 +00:00
|
|
|
export var obs:any = {
|
|
|
|
add: function(paramNameArg = "undefined",objectArg = "undefined") {
|
|
|
|
if (paramNameArg == "undefined"){
|
2016-02-23 14:03:14 +00:00
|
|
|
beautylog.error("paramName is undefined");
|
2016-02-17 20:44:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (objectArg == "undefined"){
|
2016-02-23 14:03:14 +00:00
|
|
|
beautylog.error("objectArg is undefined");
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
if (typeof obsItems[paramNameArg] === "undefined"){
|
|
|
|
obsItems[paramNameArg] = objectArg;
|
|
|
|
} else {
|
2016-02-23 14:03:14 +00:00
|
|
|
beautylog.error("object is already present, so add operation has failed.");
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
return obsItems[paramNameArg];
|
|
|
|
},
|
|
|
|
replace: function(paramNameArg,objectArg){
|
|
|
|
obsItems[paramNameArg] = objectArg;
|
|
|
|
},
|
|
|
|
merge: function(paramNameArg,objectArg){
|
|
|
|
if(!(typeof obsItems[paramNameArg] === "undefined")){
|
|
|
|
obsItems[paramNameArg] = plugins._.assign(obsItems[paramNameArg],objectArg);
|
|
|
|
} else {
|
2016-02-23 14:03:14 +00:00
|
|
|
beautylog.error("object is not present, so there is nothing to merge");
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
get: function(keyName) {
|
|
|
|
return obsItems[keyName];
|
|
|
|
},
|
|
|
|
getAll: function () {
|
|
|
|
return obsItems;
|
|
|
|
},
|
|
|
|
addComplete: function(itemsArg) {
|
|
|
|
obsItems = plugins._.assign(obsItems,itemsArg);
|
|
|
|
return obsItems;
|
2015-11-30 18:58:35 +00:00
|
|
|
}
|
2016-02-17 20:44:40 +00:00
|
|
|
};
|
|
|
|
export var obsItems:any = {};
|