From 535e941125bc5885f7d96e4654094b5aad11a21b Mon Sep 17 00:00:00 2001
From: "(quasar) nebula" <qznebula@protonmail.com>
Date: Sun, 12 Jan 2025 20:17:52 -0400
Subject: cacheable-object: mark cache valid / finalization after success

---
 src/data/cacheable-object.js | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/data')

diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index 2e136bfe..4b354ef7 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -45,7 +45,6 @@ export default class CacheableObject {
       throw new Error(`Expected constructor ${this.name} to provide CacheableObject.propertyDescriptors`);
     }
 
-    this[CacheableObject.constructorFinalized] = true;
     this[CacheableObject.propertyDependants] = Object.create(null);
 
     const propertyDescriptors = this[CacheableObject.propertyDescriptors];
@@ -116,8 +115,6 @@ export default class CacheableObject {
             return this[CacheableObject.cachedValue][property];
           }
 
-          this[CacheableObject.cacheValid][property] = true;
-
           const dependencies = Object.create(null);
           for (const key of expose.dependencies ?? []) {
             switch (key) {
@@ -141,6 +138,7 @@ export default class CacheableObject {
               : expose.compute(dependencies));
 
           this[CacheableObject.cachedValue][property] = value;
+          this[CacheableObject.cacheValid][property] = true;
 
           return value;
         };
@@ -176,6 +174,8 @@ export default class CacheableObject {
 
       Object.defineProperty(this.prototype, property, definition);
     }
+
+    this[CacheableObject.constructorFinalized] = true;
   }
 
   static getPropertyDescriptor(property) {
-- 
cgit 1.3.0-6-gf8a5