Ensure patched assertions are added before being removed, to avoid glitching

This commit is contained in:
Tony Garnock-Jones 2018-11-02 00:16:00 +00:00
parent e4782b8406
commit e9c79dca1f
2 changed files with 20 additions and 1 deletions

View File

@ -73,6 +73,17 @@ new Ground(() => {
});
return [Syndicate.Observe(BoxState(_$)), handler];
});
Dataspace.currentFacet().addEndpoint(() => {
let handler = Skeleton.analyzeAssertion(BoxState(__));
handler.callback = Dataspace.wrap((evt, vs) => {
if (evt === Skeleton.EVENT_REMOVED) {
Dataspace.currentFacet().actor.scheduleScript(() => {
console.log('box gone');
});
}
});
return [Syndicate.Observe(BoxState(__)), handler];
});
});
}).start().addStopHandler(() => {
console.timeEnd('box-and-client-' + N.toString());

View File

@ -200,12 +200,20 @@ Dataspace.prototype.addActor = function (name, bootProc, initialAssertions) {
};
Dataspace.prototype.applyPatch = function (ac, delta) {
let removals = [];
delta.forEach((count, a) => {
if (a !== void 0) {
this.index.adjustAssertion(a, count);
if (count > 0) {
this.index.adjustAssertion(a, count);
} else {
removals.push([count, a]);
}
ac.cleanupChanges.change(a, -count);
}
});
removals.forEach(([count, a]) => {
this.index.adjustAssertion(a, count);
});
};
Dataspace.prototype.subscribe = function (handler) {