[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:
@@ -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
|
// General-purpose refresh mechanism; should set up the scope
|
||||||
// as appropriate for current representation key and
|
// as appropriate for current representation key and
|
||||||
// domain object.
|
// domain object.
|
||||||
@@ -152,10 +160,8 @@ define(
|
|||||||
// via the "inclusion" field
|
// via the "inclusion" field
|
||||||
$scope.inclusion = representation && getPath(representation);
|
$scope.inclusion = representation && getPath(representation);
|
||||||
|
|
||||||
// Any existing gestures are no longer valid; release them.
|
// Any existing representers are no longer valid; release them.
|
||||||
activeRepresenters.forEach(function (activeRepresenter) {
|
destroyRepresenters();
|
||||||
activeRepresenter.destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Log if a key was given, but no matching representation
|
// Log if a key was given, but no matching representation
|
||||||
// was found.
|
// was found.
|
||||||
@@ -209,6 +215,10 @@ define(
|
|||||||
// model's "modified" field, by the mutation capability.
|
// model's "modified" field, by the mutation capability.
|
||||||
$scope.$watch("domainObject.getModel().modified", refreshCapabilities);
|
$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
|
// 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
|
||||||
// do this can result in unstable digest cycles, which
|
// do this can result in unstable digest cycles, which
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ define(
|
|||||||
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
||||||
return url;
|
return url;
|
||||||
});
|
});
|
||||||
mockScope = jasmine.createSpyObj("scope", [ "$watch" ]);
|
mockScope = jasmine.createSpyObj("scope", [ "$watch", "$on" ]);
|
||||||
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
mockElement = jasmine.createSpyObj("element", JQLITE_FUNCTIONS);
|
||||||
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
mockDomainObject = jasmine.createSpyObj("domainObject", DOMAIN_OBJECT_METHODS);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user