@statezero/core 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,7 +57,17 @@ export function QuerySetAdaptor(liveQuerySet, reactivityFn = reactive) {
|
|
|
57
57
|
const cacheKey = queryset.semanticKey;
|
|
58
58
|
// Check the cache first
|
|
59
59
|
if (cacheKey && wrappedQuerysetCache.has(cacheKey)) {
|
|
60
|
-
|
|
60
|
+
const cachedWrapper = wrappedQuerysetCache.get(cacheKey);
|
|
61
|
+
// Refresh the cached wrapper with current data
|
|
62
|
+
const freshData = [...liveQuerySet];
|
|
63
|
+
if (reactivityFn === ref) {
|
|
64
|
+
cachedWrapper.value = freshData;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
cachedWrapper.splice(0, cachedWrapper.length);
|
|
68
|
+
cachedWrapper.push(...freshData);
|
|
69
|
+
}
|
|
70
|
+
return cachedWrapper;
|
|
61
71
|
}
|
|
62
72
|
const querysetAst = queryset.build();
|
|
63
73
|
// Make the queryset reactive using the specified function
|
|
@@ -79,10 +89,10 @@ export function QuerySetAdaptor(liveQuerySet, reactivityFn = reactive) {
|
|
|
79
89
|
// Subscribe to queryset events indefinitely
|
|
80
90
|
querysetEventEmitter.on(eventName, renderHandler);
|
|
81
91
|
/* Dont delete the innocuous looking queryset.length check. There is some weird interaction
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
with vue, where when we load an empty queryset from the cache, the reactivity completely breaks.
|
|
93
|
+
I wasted over 2 days on this bug, and it won't show up in the e2e tests because it just impacts the
|
|
94
|
+
vue reactivity. If this causes performance issues, and needs to be refactored. Make sure you understand
|
|
95
|
+
the vue reactivity interaction correctly and find a different way to fix the broken reactivity for empty querysets */
|
|
86
96
|
if (cacheKey && liveQuerySet && liveQuerySet.length > 0) {
|
|
87
97
|
wrappedQuerysetCache.set(cacheKey, wrapper);
|
|
88
98
|
}
|
|
@@ -98,7 +108,10 @@ export function MetricAdaptor(metric) {
|
|
|
98
108
|
const cacheKey = `${configKey}::${modelName}::${metric.metricType}::${metric.field}::${hash(querysetAst)}`;
|
|
99
109
|
// Check the cache first
|
|
100
110
|
if (cacheKey && wrappedMetricCache.has(cacheKey)) {
|
|
101
|
-
|
|
111
|
+
const cachedWrapper = wrappedMetricCache.get(cacheKey);
|
|
112
|
+
// Refresh the cached wrapper with current metric value
|
|
113
|
+
cachedWrapper.value = metric.value;
|
|
114
|
+
return cachedWrapper;
|
|
102
115
|
}
|
|
103
116
|
// Create a reactive reference with the initial value
|
|
104
117
|
const wrapper = ref(metric.value);
|
|
@@ -116,7 +129,7 @@ export function MetricAdaptor(metric) {
|
|
|
116
129
|
}
|
|
117
130
|
};
|
|
118
131
|
// Only listen for metric render events
|
|
119
|
-
metricEventEmitter.on(
|
|
132
|
+
metricEventEmitter.on("metric::render", metricRenderHandler);
|
|
120
133
|
// Store in cache
|
|
121
134
|
if (cacheKey) {
|
|
122
135
|
wrappedMetricCache.set(cacheKey, wrapper);
|
package/package.json
CHANGED