From 4d0cc4b2f792f9b5cacb2e06c48e1ff01e6cbc2b Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 18 Dec 2023 10:32:37 +1300 Subject: [PATCH] Deduplicate subject updates. Fixes #3. --- packages/core/src/runtime/dataflow.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/runtime/dataflow.ts b/packages/core/src/runtime/dataflow.ts index b980bb5..141a2b2 100644 --- a/packages/core/src/runtime/dataflow.ts +++ b/packages/core/src/runtime/dataflow.ts @@ -95,10 +95,14 @@ export class Graph implements ObservingGraph { if (workSet.size === 0) break; + const updatedSubjects = new FlexSet(this.subjectIdCanonicalizer); workSet.forEach(objectId => { this.observersOf(objectId).forEach((subjectId: SubjectId) => { - this.forgetSubject(subjectId); - this.withSubject(subjectId, () => repairNode(subjectId)); + if (!updatedSubjects.has(subjectId)) { + updatedSubjects.add(subjectId); + this.forgetSubject(subjectId); + this.withSubject(subjectId, () => repairNode(subjectId)); + } }); }); }