Protect init and done blocks with withCurrentFacet.

This commit is contained in:
Tony Garnock-Jones 2016-05-10 17:02:31 -04:00
parent 00b0ef63eb
commit b8e076188c
1 changed files with 6 additions and 2 deletions

View File

@ -181,7 +181,9 @@ Facet.prototype.completeBuild = function() {
if (this.parent) {
this.parent.children = this.parent.children.add(this);
}
this.initBlocks.forEach(function(b) { b.call(facet.actor.state); });
withCurrentFacet(facet, function () {
facet.initBlocks.forEach(function(b) { b.call(facet.actor.state); });
});
};
Facet.prototype.terminate = function() {
@ -197,7 +199,9 @@ Facet.prototype.terminate = function() {
this.parent.children = this.parent.children.remove(this);
}
this.actor.removeFacet(this);
this.doneBlocks.forEach(function(b) { b.call(facet.actor.state); });
withCurrentFacet(facet, function () {
facet.doneBlocks.forEach(function(b) { b.call(facet.actor.state); });
});
this.children.forEach(function (child) {
child.terminate();
});