@converse/skeletor 3.1.3 → 3.1.4
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/CHANGES.md +12 -0
- package/README.md +3 -2
- package/dist/skeletor.d.ts +3 -3
- package/dist/skeletor.esm.js +9 -9
- package/dist/skeletor.esm.js.map +1 -1
- package/dist/skeletor.js +9 -9
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +3 -3
- package/dist/skeletor.node.js +9 -9
- package/dist/skeletor.node.mjs +9 -9
- package/package.json +1 -1
- package/src/collection.ts +5 -5
- package/src/model.ts +6 -6
package/dist/skeletor.js
CHANGED
|
@@ -10913,18 +10913,18 @@
|
|
|
10913
10913
|
this.initialize.apply(this, arguments);
|
|
10914
10914
|
// Reset changed after initial set
|
|
10915
10915
|
this.changed = {};
|
|
10916
|
-
// When autoSync is on, `
|
|
10917
|
-
// uniformly `await model.
|
|
10916
|
+
// When autoSync is on, `hydrated` is always a Promise so callers can
|
|
10917
|
+
// uniformly `await model.hydrated`. It only hydrates from storage when
|
|
10918
10918
|
// there's something to load (storage configured and the model isn't new);
|
|
10919
10919
|
// otherwise it's already ready and resolves immediately.
|
|
10920
10920
|
if (this.autoSync) {
|
|
10921
10921
|
if (getStorage(this) && !this.isNew()) {
|
|
10922
10922
|
__classPrivateFieldSet(this, _Model_state, 'hydrating', "f");
|
|
10923
|
-
this.
|
|
10923
|
+
this.hydrated = __classPrivateFieldGet(this, _Model_instances, "m", _Model_hydrate).call(this);
|
|
10924
10924
|
}
|
|
10925
10925
|
else {
|
|
10926
10926
|
__classPrivateFieldSet(this, _Model_state, 'ready', "f");
|
|
10927
|
-
this.
|
|
10927
|
+
this.hydrated = Promise.resolve();
|
|
10928
10928
|
}
|
|
10929
10929
|
}
|
|
10930
10930
|
else {
|
|
@@ -11097,7 +11097,7 @@
|
|
|
11097
11097
|
// Guard must come after arg normalization: when called as set(obj, opts),
|
|
11098
11098
|
// fromStorage lives in `val` (second arg), not `options` (third arg).
|
|
11099
11099
|
if (this.autoSync && __classPrivateFieldGet(this, _Model_state, "f") === 'hydrating' && !options.fromStorage) {
|
|
11100
|
-
throw new Error(`Skeletor: set() called on an autoSync model before
|
|
11100
|
+
throw new Error(`Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.`);
|
|
11101
11101
|
}
|
|
11102
11102
|
// Run validation.
|
|
11103
11103
|
if (!this._validate(attrs, options))
|
|
@@ -11537,11 +11537,11 @@
|
|
|
11537
11537
|
if (models)
|
|
11538
11538
|
this.reset(models, Object.assign({ silent: true }, options));
|
|
11539
11539
|
this[Symbol.iterator] = this.values;
|
|
11540
|
-
// When autoSync is on, `
|
|
11541
|
-
// uniformly `await collection.
|
|
11540
|
+
// When autoSync is on, `hydrated` is always a Promise so callers can
|
|
11541
|
+
// uniformly `await collection.hydrated`; it resolves immediately when
|
|
11542
11542
|
// there's no storage to hydrate from.
|
|
11543
11543
|
if (this.autoSync) {
|
|
11544
|
-
this.
|
|
11544
|
+
this.hydrated = getStorage(this) ? __classPrivateFieldGet(this, _Collection_instances, "m", _Collection_hydrate).call(this) : Promise.resolve();
|
|
11545
11545
|
}
|
|
11546
11546
|
}
|
|
11547
11547
|
get comparator() {
|
|
@@ -11573,7 +11573,7 @@
|
|
|
11573
11573
|
}
|
|
11574
11574
|
/**
|
|
11575
11575
|
* Override to return `true` to automatically load the collection from
|
|
11576
|
-
* storage on construction. Await `
|
|
11576
|
+
* storage on construction. Await `hydrated` to know when hydration
|
|
11577
11577
|
* is complete.
|
|
11578
11578
|
*
|
|
11579
11579
|
* Note: collection `autoSync` is hydrate-only. Unlike `Model`, it does
|