[Conditions] ConditionManager should observe its own mutations (#2748)

* change blur listener to change listener to watch for immediate updates to input

* move observe ConditionManager logic into ConditionManager
This commit is contained in:
David Tsay 2020-03-16 10:14:46 -07:00 committed by GitHub
parent 83c648cc26
commit 41c79c6032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -32,6 +32,10 @@ export default class ConditionManager extends EventEmitter {
this.timeAPI = this.openmct.time;
this.latestTimestamp = {};
this.initialize();
this.stopObservingForChanges = this.openmct.objects.observe(this.conditionSetDomainObject, '*', (newDomainObject) => {
this.update(newDomainObject);
});
}
initialize() {
@ -48,6 +52,9 @@ export default class ConditionManager extends EventEmitter {
update(newDomainObject) {
this.destroy();
this.conditionSetDomainObject = newDomainObject;
this.stopObservingForChanges = this.openmct.objects.observe(this.conditionSetDomainObject, '*', (newDO) => {
this.update(newDO);
});
this.initialize();
}
@ -218,6 +225,9 @@ export default class ConditionManager extends EventEmitter {
}
destroy() {
if(this.stopObservingForChanges) {
this.stopObservingForChanges();
}
this.conditionClassCollection.forEach((condition) => {
condition.off('conditionResultUpdated', this.handleConditionResult);
condition.destroy();

View File

@ -43,16 +43,9 @@ export default class ConditionSetTelemetryProvider {
let conditionManager = new ConditionManager(domainObject, this.openmct);
conditionManager.on('conditionSetResultUpdated', callback);
let stopObservingForChanges = this.openmct.objects.observe(domainObject, '*', (newDomainObject) => {
conditionManager.update(newDomainObject);
});
return function unsubscribe() {
conditionManager.off('conditionSetResultUpdated');
conditionManager.destroy();
if (stopObservingForChanges) {
stopObservingForChanges();
}
}
}
}

View File

@ -52,7 +52,7 @@
<input v-model="criterion.input[inputIndex]"
class="c-cdef__control__input"
type="text"
@blur="persist"
@change="persist"
>
<span v-if="inputIndex < inputCount-1">and</span>
</span>