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();