From 782f24687fec814e2adfe59aec77b97cdf2b32dc Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Wed, 17 Apr 2024 13:22:05 +0200 Subject: [PATCH] Track observers per-assertion, not per-observer-ref, to repair incremental updates of pattern (!) --- packages/core/src/runtime/dataspace.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/core/src/runtime/dataspace.ts b/packages/core/src/runtime/dataspace.ts index d1cc910..d4069b9 100644 --- a/packages/core/src/runtime/dataspace.ts +++ b/packages/core/src/runtime/dataspace.ts @@ -79,7 +79,7 @@ export class Dataspace implements Partial { readonly options: DataspaceOptions; readonly index = new Index(); readonly handleMap = new IdentityMap(); - readonly observerMap = new IdentityMap(); + readonly observerMap = new KeyedDictionary(); readonly data = this; constructor(options?: DataspaceOptions) { @@ -92,10 +92,9 @@ export class Dataspace implements Partial { 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 { 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();