dataflux 1.9.0 → 1.9.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 +29 -15
- package/dist/dataflux.min.js +1 -1
- package/dist/dataflux.min.js.map +1 -1
- package/package.json +8 -8
package/dist/PersistentStore.js
CHANGED
|
@@ -152,17 +152,29 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
_defineProperty(_assertThisInitialized(_this), "delayedSave", function () {
|
|
155
|
-
|
|
156
|
-
if (_this.
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
return new Promise(function (resolve, reject) {
|
|
156
|
+
if (_this.options.autoSave) {
|
|
157
|
+
if (_this._delayedSaveTimer) {
|
|
158
|
+
_this._delayedSavePromise();
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
_this._delayedSavePromise = null;
|
|
161
|
+
clearTimeout(_this._delayedSaveTimer);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
_this._delayedSavePromise = resolve;
|
|
165
|
+
_this._delayedSaveTimer = setTimeout(function () {
|
|
166
|
+
resolve(_this.save());
|
|
167
|
+
_this._delayedSavePromise = null;
|
|
168
|
+
}, _this.options.saveDelay);
|
|
169
|
+
} else {
|
|
170
|
+
resolve();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
162
173
|
});
|
|
163
174
|
|
|
164
175
|
_this._busy = false;
|
|
165
176
|
_this._delayedSaveTimer = null;
|
|
177
|
+
_this._delayedSavePromise = null;
|
|
166
178
|
|
|
167
179
|
if (typeof _this.options.autoSave === "number") {
|
|
168
180
|
setInterval(function () {
|
|
@@ -191,9 +203,9 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
191
203
|
var _this3 = this;
|
|
192
204
|
|
|
193
205
|
return _get(_getPrototypeOf(PersistentStore.prototype), "insert", this).call(this, type, objects).then(function (data) {
|
|
194
|
-
_this3.delayedSave()
|
|
195
|
-
|
|
196
|
-
|
|
206
|
+
return _this3.delayedSave().then(function () {
|
|
207
|
+
return data;
|
|
208
|
+
});
|
|
197
209
|
});
|
|
198
210
|
}
|
|
199
211
|
}, {
|
|
@@ -207,9 +219,9 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
207
219
|
var _this4 = this;
|
|
208
220
|
|
|
209
221
|
return _get(_getPrototypeOf(PersistentStore.prototype), "delete", this).call(this, typeOrObjects, filterFunction).then(function (data) {
|
|
210
|
-
_this4.delayedSave()
|
|
211
|
-
|
|
212
|
-
|
|
222
|
+
return _this4.delayedSave().then(function () {
|
|
223
|
+
return data;
|
|
224
|
+
});
|
|
213
225
|
});
|
|
214
226
|
}
|
|
215
227
|
}, {
|
|
@@ -233,11 +245,13 @@ var PersistentStore = /*#__PURE__*/function (_Store) {
|
|
|
233
245
|
} finally {
|
|
234
246
|
_iterator.f();
|
|
235
247
|
}
|
|
248
|
+
|
|
249
|
+
return objects;
|
|
236
250
|
} else {
|
|
237
|
-
_this5.delayedSave()
|
|
251
|
+
return _this5.delayedSave().then(function () {
|
|
252
|
+
return objects;
|
|
253
|
+
});
|
|
238
254
|
}
|
|
239
|
-
|
|
240
|
-
return objects;
|
|
241
255
|
});
|
|
242
256
|
}
|
|
243
257
|
}]);
|