mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 07:16:39 +00:00
Use MutationCapability
This commit is contained in:
parent
bd3c6665fb
commit
b1b8df4d87
@ -11,7 +11,6 @@ define([
|
|||||||
this.objectService = objectService;
|
this.objectService = objectService;
|
||||||
this.instantiate = instantiate;
|
this.instantiate = instantiate;
|
||||||
|
|
||||||
this.topicService = topic;
|
|
||||||
this.generalTopic = topic('mutation');
|
this.generalTopic = topic('mutation');
|
||||||
this.bridgeEventBuses();
|
this.bridgeEventBuses();
|
||||||
}
|
}
|
||||||
@ -21,21 +20,20 @@ define([
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ObjectServiceProvider.prototype.bridgeEventBuses = function () {
|
ObjectServiceProvider.prototype.bridgeEventBuses = function () {
|
||||||
var generalTopicListener;
|
var removeGeneralTopicListener;
|
||||||
|
|
||||||
var handleMutation = function (newStyleObject) {
|
var handleMutation = function (newStyleObject) {
|
||||||
var keyString = utils.makeKeyString(newStyleObject.key);
|
var keyString = utils.makeKeyString(newStyleObject.key);
|
||||||
var oldStyleObject = this.instantiate(utils.toOldFormat(newStyleObject), keyString);
|
var oldStyleObject = this.instantiate(utils.toOldFormat(newStyleObject), keyString);
|
||||||
var specificTopic = this.topicService("mutation:" + keyString);
|
|
||||||
|
|
||||||
// Don't trigger self
|
// Don't trigger self
|
||||||
if (generalTopicListener){
|
removeGeneralTopicListener();
|
||||||
generalTopicListener();
|
|
||||||
}
|
|
||||||
this.generalTopic.notify(oldStyleObject);
|
|
||||||
specificTopic.notify(oldStyleObject.getModel());
|
|
||||||
|
|
||||||
generalTopicListener = this.generalTopic.listen(handleLegacyMutation);
|
oldStyleObject.getCapability('mutation').mutate(function () {
|
||||||
|
return utils.toOldFormat(newStyleObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
removeGeneralTopicListener = this.generalTopic.listen(handleLegacyMutation);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
var handleLegacyMutation = function (legacyObject){
|
var handleLegacyMutation = function (legacyObject){
|
||||||
@ -48,7 +46,7 @@ define([
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
objectEventEmitter.on('mutation', handleMutation);
|
objectEventEmitter.on('mutation', handleMutation);
|
||||||
generalTopicListener = this.generalTopic.listen(handleLegacyMutation);
|
removeGeneralTopicListener = this.generalTopic.listen(handleLegacyMutation);
|
||||||
};
|
};
|
||||||
|
|
||||||
ObjectServiceProvider.prototype.save = function (object) {
|
ObjectServiceProvider.prototype.save = function (object) {
|
||||||
|
Loading…
Reference in New Issue
Block a user