@nuxodin/item 0.6.13 → 0.6.14
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.
- package/package.json +1 -1
- package/src/AsyncDataPoint.js +6 -2
package/package.json
CHANGED
package/src/AsyncDataPoint.js
CHANGED
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
#getter = null; // current/cached getter promise
|
|
25
25
|
#getterExpiry = Infinity; // ttl is checked lazily on access — no timer per cache entry
|
|
26
26
|
// expired getters count as gone (lazy ttl)
|
|
27
|
-
get #cachedGetter() {
|
|
27
|
+
get #cachedGetter() {
|
|
28
|
+
const g = this.#getter;
|
|
29
|
+
return g && (this.#getterExpiry === Infinity || Date.now() < this.#getterExpiry) ? g : null;
|
|
30
|
+
}
|
|
28
31
|
onpending = null;
|
|
29
32
|
onchange = null;
|
|
30
33
|
|
|
@@ -128,7 +131,8 @@
|
|
|
128
131
|
|
|
129
132
|
// ignore if latest getter value is the same
|
|
130
133
|
// Value already set (no-op). Returns undefined to avoid falsy issues (value could be 0, false, etc.)
|
|
131
|
-
|
|
134
|
+
const cached = this.#cachedGetter;
|
|
135
|
+
if (cached?.state === 'fulfilled' && isEqual(cached.value, value)) return;
|
|
132
136
|
|
|
133
137
|
this.#expectedValue = value;
|
|
134
138
|
const promise = this.#createSetter(value);
|