dataflux 1.13.0 → 1.13.1
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/dist/PersistentStore.js +5 -3
- package/dist/Store.js +6 -3
- package/dist/dataflux.min.js +1 -1
- package/dist/dataflux.min.js.map +1 -1
- package/package.json +1 -1
package/dist/PersistentStore.js
CHANGED
|
@@ -78,7 +78,9 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
78
78
|
if (_this._delayedSaveTimer) {
|
|
79
79
|
clearTimeout(_this._delayedSaveTimer);
|
|
80
80
|
}
|
|
81
|
-
return Promise.all(Object.keys(_this.models).map(
|
|
81
|
+
return Promise.all(Object.keys(_this.models).map(function (i) {
|
|
82
|
+
return _this._saveByType(i, true);
|
|
83
|
+
})).then(function (data) {
|
|
82
84
|
_this._busy = false;
|
|
83
85
|
_this.pubSub.publish("save", "end");
|
|
84
86
|
return data;
|
|
@@ -134,8 +136,8 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
134
136
|
}, type);
|
|
135
137
|
});
|
|
136
138
|
});
|
|
137
|
-
_defineProperty(_assertThisInitialized(_this), "_saveByType", function (type) {
|
|
138
|
-
return _this.getDiff(type).then(function (diff) {
|
|
139
|
+
_defineProperty(_assertThisInitialized(_this), "_saveByType", function (type, ifLoaded) {
|
|
140
|
+
return _this.getDiff(type, ifLoaded).then(function (diff) {
|
|
139
141
|
return _this._saveDiff(type, diff);
|
|
140
142
|
});
|
|
141
143
|
});
|
package/dist/Store.js
CHANGED
|
@@ -384,9 +384,9 @@ var Store = /*#__PURE__*/function () {
|
|
|
384
384
|
}
|
|
385
385
|
}, {
|
|
386
386
|
key: "getDiff",
|
|
387
|
-
value: function getDiff(type) {
|
|
387
|
+
value: function getDiff(type, ifLoaded) {
|
|
388
388
|
var _this8 = this;
|
|
389
|
-
return this._getPromise(type).then(function () {
|
|
389
|
+
return this._getPromise(type, ifLoaded).then(function () {
|
|
390
390
|
var objects = Object.values(_this8.models[type].storedObjects);
|
|
391
391
|
var inserted = [];
|
|
392
392
|
var updated = [];
|
|
@@ -442,14 +442,17 @@ var Store = /*#__PURE__*/function () {
|
|
|
442
442
|
key: "_getPromise",
|
|
443
443
|
value: function _getPromise(type) {
|
|
444
444
|
var _this10 = this;
|
|
445
|
+
var ifLoaded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
445
446
|
if (!this.models[type]) {
|
|
446
447
|
return Promise.reject("The model doesn't exist");
|
|
447
448
|
} else if (!this.models[type].promise && !this.options.lazyLoad) {
|
|
448
449
|
return Promise.reject("The model is not loaded");
|
|
449
|
-
} else if (!this.models[type].promise && this.options.lazyLoad) {
|
|
450
|
+
} else if (!this.models[type].promise && this.options.lazyLoad && !ifLoaded) {
|
|
450
451
|
return _classPrivateMethodGet(this, _loadObjects, _loadObjects2).call(this, type).then(function () {
|
|
451
452
|
return _this10.models[type].promise;
|
|
452
453
|
});
|
|
454
|
+
} else if (!this.models[type].promise && this.options.lazyLoad && ifLoaded) {
|
|
455
|
+
return Promise.resolve();
|
|
453
456
|
} else {
|
|
454
457
|
return this.models[type].promise;
|
|
455
458
|
}
|