Ensure patched assertions are added before being removed, to avoid glitching
This commit is contained in:
parent
e4782b8406
commit
e9c79dca1f
|
@ -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());
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue