mirror of
https://github.com/nasa/openmct.git
synced 2025-04-11 21:31:06 +00:00
[Representers] Destroy representers
Invoke the destroy methods of any active representers when a scope is destroyed; supports time controller, which needs to accurately track when it has or hasn't been attached to a view. WTD-1515
This commit is contained in:
parent
4d276888e1
commit
29c460556a
@ -136,6 +136,14 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy (deallocate any resources associated with) any
|
||||
// active representers.
|
||||
function destroyRepresenters() {
|
||||
activeRepresenters.forEach(function (activeRepresenter) {
|
||||
activeRepresenter.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
// General-purpose refresh mechanism; should set up the scope
|
||||
// as appropriate for current representation key and
|
||||
// domain object.
|
||||
@ -152,10 +160,8 @@ define(
|
||||
// via the "inclusion" field
|
||||
$scope.inclusion = representation && getPath(representation);
|
||||
|
||||
// Any existing gestures are no longer valid; release them.
|
||||
activeRepresenters.forEach(function (activeRepresenter) {
|
||||
activeRepresenter.destroy();
|
||||
});
|
||||
// Any existing representers are no longer valid; release them.
|
||||
destroyRepresenters();
|
||||
|
||||
// Log if a key was given, but no matching representation
|
||||
// was found.
|
||||
@ -209,6 +215,10 @@ define(
|
||||
// model's "modified" field, by the mutation capability.
|
||||
$scope.$watch("domainObject.getModel().modified", refreshCapabilities);
|
||||
|
||||
// Make sure any resources allocated by representers also get
|
||||
// released.
|
||||
$scope.$on("$destroy", destroyRepresenters);
|
||||
|
||||
// Do one initial refresh, so that we don't need another
|
||||
// digest iteration just to populate the scope. Failure to
|
||||
// do this can result in unstable digest cycles, which
|
||||
|
@ -106,7 +106,7 @@ define(
|
||||
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
||||
return url;
|
||||
});
|
||||
mockScope = jasmine.createSpyObj("scope", [ "$watch" ]);
|
||||
mockScope = jasmine.createSpyObj("scope", [ "$watch", "$on" ]);
|
||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user