Track observers per-assertion, not per-observer-ref, to repair incremental updates of pattern (!)
This commit is contained in:
parent
6d904d276e
commit
782f24687f
|
@ -79,7 +79,7 @@ export class Dataspace implements Partial<Entity> {
|
|||
readonly options: DataspaceOptions;
|
||||
readonly index = new Index();
|
||||
readonly handleMap = new IdentityMap<Handle, Assertion>();
|
||||
readonly observerMap = new IdentityMap<Ref, DataspaceObserver>();
|
||||
readonly observerMap = new KeyedDictionary<Ref, Observe, DataspaceObserver>();
|
||||
readonly data = this;
|
||||
|
||||
constructor(options?: DataspaceOptions) {
|
||||
|
@ -92,10 +92,9 @@ export class Dataspace implements Partial<Entity> {
|
|||
if (is_new) {
|
||||
const o = toObserve(strip(v));
|
||||
if (o !== void 0) {
|
||||
const target = o.observer;
|
||||
const observer = new DataspaceObserver(target);
|
||||
this.observerMap.set(target, observer);
|
||||
this.index.addObserver(o.pattern, observer, Turn.active);
|
||||
const io = new DataspaceObserver(o.observer);
|
||||
this.observerMap.set(o, io);
|
||||
this.index.addObserver(o.pattern, io, Turn.active);
|
||||
}
|
||||
if (this.options.dumpIndex ?? false) this.index.dump();
|
||||
}
|
||||
|
@ -111,10 +110,10 @@ export class Dataspace implements Partial<Entity> {
|
|||
if (is_last) {
|
||||
const o = toObserve(strip(v));
|
||||
if (o !== void 0) {
|
||||
const io = this.observerMap.get(o.observer);
|
||||
const io = this.observerMap.get(o);
|
||||
if (io !== void 0) {
|
||||
this.index.removeObserver(o.pattern, io, Turn.active);
|
||||
this.observerMap.delete(o.observer);
|
||||
this.observerMap.delete(o);
|
||||
}
|
||||
}
|
||||
if (this.options.dumpIndex ?? false) this.index.dump();
|
||||
|
|
Loading…
Reference in New Issue