« get me outta code hell

data: roll paired "byRef" and "dynamic" properties into one - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/cacheable-object.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-07 17:30:54 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-07 17:30:54 -0300
commitbbccaf51222cb4bed73466164496f5bc1030292c (patch)
treefc26c89f44b84140ba01b9edabedef10c73a637a /src/data/things/cacheable-object.js
parentc18844784bd1c0ead7c49d0519727b7a92e23e13 (diff)
data: roll paired "byRef" and "dynamic" properties into one
Diffstat (limited to 'src/data/things/cacheable-object.js')
-rw-r--r--src/data/things/cacheable-object.js26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/data/things/cacheable-object.js b/src/data/things/cacheable-object.js
index 92a46d66..4bc3668d 100644
--- a/src/data/things/cacheable-object.js
+++ b/src/data/things/cacheable-object.js
@@ -86,16 +86,14 @@ export default class CacheableObject {
   #propertyUpdateValues = Object.create(null);
   #propertyUpdateCacheInvalidators = Object.create(null);
 
-  /*
-    // Note the constructor doesn't take an initial data source. Due to a quirk
-    // of JavaScript, private members can't be accessed before the superclass's
-    // constructor is finished processing - so if we call the overridden
-    // update() function from inside this constructor, it will error when
-    // writing to private members. Pretty bad!
-    //
-    // That means initial data must be provided by following up with update()
-    // after constructing the new instance of the Thing (sub)class.
-    */
+  // Note the constructor doesn't take an initial data source. Due to a quirk
+  // of JavaScript, private members can't be accessed before the superclass's
+  // constructor is finished processing - so if we call the overridden
+  // update() function from inside this constructor, it will error when
+  // writing to private members. Pretty bad!
+  //
+  // That means initial data must be provided by following up with update()
+  // after constructing the new instance of the Thing (sub)class.
 
   constructor() {
     this.#defineProperties();
@@ -352,4 +350,12 @@ export default class CacheableObject {
       console.log(` - ${line}`);
     }
   }
+
+  static getUpdateValue(object, key) {
+    if (!Object.hasOwn(object, key)) {
+      return undefined;
+    }
+
+    return object.#propertyUpdateValues[key] ?? null;
+  }
 }