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,8 +35,11 @@ define([],
this.id = id; this.id = id;
this.hasFrame = hasFrame; this.hasFrame = hasFrame;
this.rawPosition = rawPosition; this.rawPosition = rawPosition;
this.openmct = openmct;
this.mutatePosition = this.mutatePosition.bind(this); 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 = []; this.listeners = [];
} }
@ -46,17 +49,13 @@ define([],
this.mutate(path + ".position", this.rawPosition.position); this.mutate(path + ".position", this.rawPosition.position);
} }
mutate(path, value) {
this.openmct.objects.mutate(this.domainObject, path, value);
}
attachListeners() { attachListeners() {
let path = "configuration.panels[" + this.id + "].hasFrame"; 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; this.hasFrame = newValue;
}.bind(this))); }.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)); this.domainObject = JSON.parse(JSON.stringify(obj));
}.bind(this))); }.bind(this)));
} }

View File

@ -34,7 +34,10 @@ define([],
this.domainObject = domainObject; this.domainObject = domainObject;
this.alphanumeric = alphanumeric; this.alphanumeric = alphanumeric;
this.rawPosition = rawPosition; 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.mutatePosition = this.mutatePosition.bind(this);
this.listeners = []; this.listeners = [];
} }
@ -56,12 +59,12 @@ define([],
'size' 'size'
].forEach(property => { ].forEach(property => {
this.listeners.push( 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; this.alphanumeric[property] = newValue;
}.bind(this)) }.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)); this.domainObject = JSON.parse(JSON.stringify(obj));
}.bind(this))); }.bind(this)));
} }
@ -73,10 +76,6 @@ define([],
this.listeners = []; this.listeners = [];
} }
mutate(path, value) {
this.openmct.objects.mutate(this.domainObject, path, value);
}
} }
return TelemetryViewConfiguration; return TelemetryViewConfiguration;