« get me outta code hell

data: filter only requested deps, require requesting 'this' - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/group.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-08-22 13:02:19 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-05 21:02:49 -0300
commit75691866ed68b9261dd920b79d4ab214df3f049b (patch)
tree0a8d328279498631bdab9eaa2afedcee5574c7fb /src/data/things/group.js
parent93448ef747b681d3b87b050b555311c0172b83cc (diff)
data: filter only requested deps, require requesting 'this'
* Thing.composite.from() only provides the dependencies specified
  in each step and the base, and prevents '#'-prefixed keys from
  being specified on the main (composite) dependency list.

* CacheableObject no longer provides a "reflection" dependency to
  every compute/transform function, and now requires the property
  'this' to be specified instead of the constructor.instance
  symbol. (The static CacheableObject.instance, inherited by all
  subclasses, was also removed.)

* Also minor improvements to sugar.js data processing utility
  functions.
Diffstat (limited to 'src/data/things/group.js')
-rw-r--r--src/data/things/group.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/data/things/group.js b/src/data/things/group.js
index ba339b3..f552b8f 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group.js
@@ -41,8 +41,8 @@ export class Group extends Thing {
       flags: {expose: true},
 
       expose: {
-        dependencies: ['albumData'],
-        compute: ({albumData, [Group.instance]: group}) =>
+        dependencies: ['this', 'albumData'],
+        compute: ({this: group, albumData}) =>
           albumData?.filter((album) => album.groups.includes(group)) ?? [],
       },
     },
@@ -51,9 +51,8 @@ export class Group extends Thing {
       flags: {expose: true},
 
       expose: {
-        dependencies: ['groupCategoryData'],
-
-        compute: ({groupCategoryData, [Group.instance]: group}) =>
+        dependencies: ['this', 'groupCategoryData'],
+        compute: ({this: group, groupCategoryData}) =>
           groupCategoryData.find((category) => category.groups.includes(group))
             ?.color,
       },
@@ -63,8 +62,8 @@ export class Group extends Thing {
       flags: {expose: true},
 
       expose: {
-        dependencies: ['groupCategoryData'],
-        compute: ({groupCategoryData, [Group.instance]: group}) =>
+        dependencies: ['this', 'groupCategoryData'],
+        compute: ({this: group, groupCategoryData}) =>
           groupCategoryData.find((category) => category.groups.includes(group)) ??
           null,
       },