mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
Register listener for status change
This commit is contained in:
parent
18e0aadfc1
commit
a72f193e97
@ -57,7 +57,7 @@ define(
|
|||||||
function MCTRepresentation(representations, views, representers, $q, templateLinker, $log) {
|
function MCTRepresentation(representations, views, representers, $q, templateLinker, $log) {
|
||||||
var representationMap = {},
|
var representationMap = {},
|
||||||
gestureMap = {},
|
gestureMap = {},
|
||||||
domainObjectListener;
|
listeners = 0;
|
||||||
|
|
||||||
// Assemble all representations and views
|
// Assemble all representations and views
|
||||||
// The distinction between views and representations is
|
// The distinction between views and representations is
|
||||||
@ -95,6 +95,7 @@ define(
|
|||||||
couldEdit = false,
|
couldEdit = false,
|
||||||
lastIdPath = [],
|
lastIdPath = [],
|
||||||
lastKey,
|
lastKey,
|
||||||
|
statusListener,
|
||||||
changeTemplate = templateLinker.link($scope, element);
|
changeTemplate = templateLinker.link($scope, element);
|
||||||
|
|
||||||
// Populate scope with any capabilities indicated by the
|
// Populate scope with any capabilities indicated by the
|
||||||
@ -179,8 +180,6 @@ define(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("changed");
|
|
||||||
|
|
||||||
// Create an empty object named "representation", for this
|
// Create an empty object named "representation", for this
|
||||||
// representation to store local variables into.
|
// representation to store local variables into.
|
||||||
$scope.representation = {};
|
$scope.representation = {};
|
||||||
@ -243,16 +242,18 @@ define(
|
|||||||
|
|
||||||
// Also update when the represented domain object changes
|
// Also update when the represented domain object changes
|
||||||
// (to a different object)
|
// (to a different object)
|
||||||
//$scope.$watch("domainObject", refresh);
|
$scope.$watch("domainObject", refresh);
|
||||||
|
$scope.$watch("domainObject", function(domainObject) {
|
||||||
$scope.$watch("domainObject", function (domainObject) {
|
if (domainObject){
|
||||||
if (domainObjectListener) {
|
if (statusListener) {
|
||||||
domainObjectListener();
|
statusListener();
|
||||||
|
listeners--;
|
||||||
|
console.log("directive listeners " + listeners);
|
||||||
|
}
|
||||||
|
statusListener = domainObject.getCapability("status").listen(refresh);
|
||||||
|
listeners++;
|
||||||
|
console.log("directive listeners " + listeners);
|
||||||
}
|
}
|
||||||
if (domainObject) {
|
|
||||||
domainObjectListener = domainObject.getCapability('status').listen(refresh);
|
|
||||||
}
|
|
||||||
refresh();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Finally, also update when there is a new version of that
|
// Finally, also update when there is a new version of that
|
||||||
@ -263,6 +264,13 @@ define(
|
|||||||
// Make sure any resources allocated by representers also get
|
// Make sure any resources allocated by representers also get
|
||||||
// released.
|
// released.
|
||||||
$scope.$on("$destroy", destroyRepresenters);
|
$scope.$on("$destroy", destroyRepresenters);
|
||||||
|
$scope.$on("$destroy", function () {
|
||||||
|
if (statusListener) {
|
||||||
|
statusListener();
|
||||||
|
listeners--;
|
||||||
|
console.log("directive listeners " + listeners);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Do one initial refresh, so that we don't need another
|
// Do one initial refresh, so that we don't need another
|
||||||
// digest iteration just to populate the scope. Failure to
|
// digest iteration just to populate the scope. Failure to
|
||||||
|
Loading…
Reference in New Issue
Block a user