Skip to content

Commit 1d4b311

Browse files
committed
Stable Version 2.0.0-beta.4.
1 parent 4f63c93 commit 1d4b311

File tree

6 files changed

+63
-63
lines changed

6 files changed

+63
-63
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
##### 2.0.0-beta.4 - 18 April 2015
2+
3+
Fix
4+
15
##### 2.0.0-beta.3 - 18 April 2015
26

37
###### Backwards compatible bug fixes

dist/js-data-localstorage.js

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
22
* js-data-localstorage
3-
* @version 2.0.0-beta.3 - Homepage <http://www.js-data.io/docs/dslocalstorageadapter>
3+
* @version 2.0.0-beta.4 - Homepage <http://www.js-data.io/docs/dslocalstorageadapter>
44
* @author Jason Dobry <[email protected]>
55
* @copyright (c) 2014-2015 Jason Dobry
66
* @license MIT <https://github.com/js-data/js-data-localstorage/blob/master/LICENSE>
@@ -107,34 +107,39 @@ return /******/ (function(modules) { // webpackBootstrap
107107
Defaults.prototype.basePath = '';
108108

109109
var queue = [];
110+
var taskInProcess = false;
110111

111112
function enqueue(task) {
112113
queue.push(task);
113114
}
114115

115116
function dequeue() {
116-
if (queue.length) {
117-
var task = queue.shift();
118-
task();
117+
if (queue.length && !taskInProcess) {
118+
taskInProcess = true;
119+
queue[0]();
119120
}
120121
}
121122

122123
function queueTask(task) {
123-
if (queue.length) {
124+
if (!queue.length) {
124125
enqueue(task);
126+
dequeue();
125127
} else {
126-
task();
128+
enqueue(task);
127129
}
128130
}
129131

130132
function createTask(fn) {
131133
return new DSUtils.Promise(fn).then(function (result) {
132-
setTimeout(function () {
133-
if (queue.length) {
134-
dequeue();
135-
}
136-
}, 0);
134+
taskInProcess = false;
135+
queue.shift();
136+
setTimeout(dequeue, 0);
137137
return result;
138+
}, function (err) {
139+
taskInProcess = false;
140+
queue.shift();
141+
setTimeout(dequeue, 0);
142+
return DSUtils.Promise.reject(err);
138143
});
139144
}
140145

@@ -227,7 +232,7 @@ return /******/ (function(modules) { // webpackBootstrap
227232
queueTask(function () {
228233
_this.GET(_this.getIdPath(resourceConfig, options || {}, id)).then(function (item) {
229234
return !item ? reject(new Error('Not Found!')) : resolve(item);
230-
});
235+
}, reject);
231236
});
232237
});
233238
}
@@ -296,16 +301,12 @@ return /******/ (function(modules) { // webpackBootstrap
296301
value: function updateAll(resourceConfig, attrs, params, options) {
297302
var _this5 = this;
298303

299-
return createTask(function (resolve, reject) {
300-
queueTask(function () {
301-
_this5.findAll(resourceConfig, params, options).then(function (items) {
302-
var tasks = [];
303-
forEach(items, function (item) {
304-
return tasks.push(_this5.update(resourceConfig, item[resourceConfig.idAttribute], _omit2['default'](attrs, resourceConfig.relationFields || []), options));
305-
});
306-
resolve(DSUtils.Promise.all(tasks));
307-
})['catch'](reject);
304+
return this.findAll(resourceConfig, params, options).then(function (items) {
305+
var tasks = [];
306+
forEach(items, function (item) {
307+
return tasks.push(_this5.update(resourceConfig, item[resourceConfig.idAttribute], _omit2['default'](attrs, resourceConfig.relationFields || []), options));
308308
});
309+
return DSUtils.Promise.all(tasks);
309310
});
310311
}
311312
}, {
@@ -318,7 +319,9 @@ return /******/ (function(modules) { // webpackBootstrap
318319
options = options || {};
319320
_this6.DEL(_this6.getIdPath(resourceConfig, options, id)).then(function () {
320321
return _this6.removeId(id, resourceConfig.name, options);
321-
}).then(resolve, reject);
322+
}).then(function () {
323+
return resolve(null);
324+
}, reject);
322325
});
323326
});
324327
}
@@ -327,16 +330,12 @@ return /******/ (function(modules) { // webpackBootstrap
327330
value: function destroyAll(resourceConfig, params, options) {
328331
var _this7 = this;
329332

330-
return createTask(function (resolve, reject) {
331-
queueTask(function () {
332-
_this7.findAll(resourceConfig, params, options).then(function (items) {
333-
var tasks = [];
334-
forEach(items, function (item) {
335-
return tasks.push(_this7.destroy(resourceConfig, item[resourceConfig.idAttribute], options));
336-
});
337-
resolve(DSUtils.Promise.all(tasks));
338-
})['catch'](reject);
333+
return this.findAll(resourceConfig, params, options).then(function (items) {
334+
var tasks = [];
335+
forEach(items, function (item) {
336+
return tasks.push(_this7.destroy(resourceConfig, item[resourceConfig.idAttribute], options));
339337
});
338+
return DSUtils.Promise.all(tasks);
340339
});
341340
}
342341
}]);

dist/js-data-localstorage.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)