Hide openmct with closures to prevent it becoming reactive

This commit is contained in:
Pete Richards 2018-11-09 08:33:50 -08:00
parent ff7df9ad1e
commit 0e06a7b403
2 changed files with 16 additions and 18 deletions

View File

@ -35,28 +35,27 @@ define([],
this.id = id;
this.hasFrame = hasFrame;
this.rawPosition = rawPosition;
this.openmct = openmct;
this.mutatePosition = this.mutatePosition.bind(this);
this.observe = openmct.objects.observe.bind(openmct.objects);
this.mutate = function (path, value) {
openmct.objects.mutate(this.domainObject, path, value);
}.bind(this);
this.listeners = [];
}
mutatePosition() {
let path = "configuration.panels[" + this.id + "]";
this.mutate(path + ".dimensions", this.rawPosition.dimensions);
this.mutate(path + ".position", this.rawPosition.position);
}
mutate(path, value) {
this.openmct.objects.mutate(this.domainObject, path, value);
this.mutate(path + ".position", this.rawPosition.position);
}
attachListeners() {
let path = "configuration.panels[" + this.id + "].hasFrame";
this.listeners.push(this.openmct.objects.observe(this.domainObject, path, function (newValue) {
this.listeners.push(this.observe(this.domainObject, path, function (newValue) {
this.hasFrame = newValue;
}.bind(this)));
this.listeners.push(this.openmct.objects.observe(this.domainObject, '*', function (obj) {
this.listeners.push(this.observe(this.domainObject, '*', function (obj) {
this.domainObject = JSON.parse(JSON.stringify(obj));
}.bind(this)));
}
@ -71,4 +70,4 @@ define([],
return SubobjectViewConfiguration;
}
);
);

View File

@ -34,7 +34,10 @@ define([],
this.domainObject = domainObject;
this.alphanumeric = alphanumeric;
this.rawPosition = rawPosition;
this.openmct = openmct;
this.observe = openmct.objects.observe.bind(openmct.objects);
this.mutate = function (path, value) {
openmct.objects.mutate(this.domainObject, path, value);
}.bind(this);
this.mutatePosition = this.mutatePosition.bind(this);
this.listeners = [];
}
@ -42,7 +45,7 @@ define([],
mutatePosition() {
let path = "configuration.alphanumerics[" + this.alphanumeric.index + "]";
this.mutate(path + ".dimensions", this.rawPosition.dimensions);
this.mutate(path + ".position", this.rawPosition.position);
this.mutate(path + ".position", this.rawPosition.position);
}
attachListeners() {
@ -56,12 +59,12 @@ define([],
'size'
].forEach(property => {
this.listeners.push(
this.openmct.objects.observe(this.domainObject, path + "." + property, function (newValue) {
this.observe(this.domainObject, path + "." + property, function (newValue) {
this.alphanumeric[property] = newValue;
}.bind(this))
);
});
this.listeners.push(this.openmct.objects.observe(this.domainObject, '*', function (obj) {
this.listeners.push(this.observe(this.domainObject, '*', function (obj) {
this.domainObject = JSON.parse(JSON.stringify(obj));
}.bind(this)));
}
@ -73,12 +76,8 @@ define([],
this.listeners = [];
}
mutate(path, value) {
this.openmct.objects.mutate(this.domainObject, path, value);
}
}
return TelemetryViewConfiguration;
}
);
);