Commit e2d7a5c0 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_xhtml_style/web_renderjs_ui] Update RSVP

parent 700a31c6
......@@ -556,6 +556,7 @@ define("rsvp/promise",
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
if (resolved) { return; }
promise.isCancelled = true;
if (canceller !== undefined) {
try {
canceller();
......@@ -587,6 +588,7 @@ define("rsvp/promise",
if (promise.isFulfilled) { return; }
if (promise.isRejected) { return; }
if (promise.isCancelled) { return; }
if (hasCallback) {
try {
......@@ -617,6 +619,7 @@ define("rsvp/promise",
Promise.prototype = {
constructor: Promise,
isCancelled: undefined,
isRejected: undefined,
isFulfilled: undefined,
rejectedReason: undefined,
......@@ -758,7 +761,7 @@ define("rsvp/queue",
ResolvedQueueError.prototype = new Error();
ResolvedQueueError.prototype.constructor = ResolvedQueueError;
var Queue = function() {
var Queue = function(thenable) {
var queue = this,
promise_list = [],
promise,
......@@ -771,11 +774,31 @@ define("rsvp/queue",
}
function canceller() {
for (var i = 0; i < 2; i++) {
promise_list[i].cancel();
for (var i = promise_list.length; i > 0; i--) {
promise_list[i - 1].cancel();
}
}
function checkPromise(next_promise) {
promise_list.push(next_promise);
// Handle pop
promise_list.push(next_promise.then(function (fulfillmentValue) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill(fulfillmentValue);
} else {
return fulfillmentValue;
}
}, function (rejectedReason) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
reject(rejectedReason);
} else {
throw rejectedReason;
}
}));
}
promise = new Promise(function(done, fail) {
fulfill = function (fulfillmentValue) {
if (resolved) {return;}
......@@ -793,13 +816,7 @@ define("rsvp/queue",
};
}, canceller);
promise_list.push(resolve());
promise_list.push(promise_list[0].then(function () {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill();
}
}));
checkPromise(resolve(thenable));
queue.cancel = function () {
if (resolved) {return;}
......@@ -822,25 +839,9 @@ define("rsvp/queue",
throw new ResolvedQueueError();
}
next_promise = last_promise.then(done, fail);
promise_list.push(next_promise);
// Handle pop
promise_list.push(next_promise.then(function (fulfillmentValue) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill(fulfillmentValue);
} else {
return fulfillmentValue;
}
}, function (rejectedReason) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
reject(rejectedReason);
} else {
throw rejectedReason;
}
}));
checkPromise(last_promise.then(done, fail));
return this;
};
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>977.38881.34981.23125</string> </value>
<value> <string>982.5438.65075.12680</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1576579789.68</float>
<float>1582713688.85</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -556,6 +556,7 @@ define("rsvp/promise",
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
if (resolved) { return; }
promise.isCancelled = true;
if (canceller !== undefined) {
try {
canceller();
......@@ -587,6 +588,7 @@ define("rsvp/promise",
if (promise.isFulfilled) { return; }
if (promise.isRejected) { return; }
if (promise.isCancelled) { return; }
if (hasCallback) {
try {
......@@ -617,6 +619,7 @@ define("rsvp/promise",
Promise.prototype = {
constructor: Promise,
isCancelled: undefined,
isRejected: undefined,
isFulfilled: undefined,
rejectedReason: undefined,
......@@ -758,7 +761,7 @@ define("rsvp/queue",
ResolvedQueueError.prototype = new Error();
ResolvedQueueError.prototype.constructor = ResolvedQueueError;
var Queue = function() {
var Queue = function(thenable) {
var queue = this,
promise_list = [],
promise,
......@@ -771,11 +774,31 @@ define("rsvp/queue",
}
function canceller() {
for (var i = 0; i < 2; i++) {
promise_list[i].cancel();
for (var i = promise_list.length; i > 0; i--) {
promise_list[i - 1].cancel();
}
}
function checkPromise(next_promise) {
promise_list.push(next_promise);
// Handle pop
promise_list.push(next_promise.then(function (fulfillmentValue) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill(fulfillmentValue);
} else {
return fulfillmentValue;
}
}, function (rejectedReason) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
reject(rejectedReason);
} else {
throw rejectedReason;
}
}));
}
promise = new Promise(function(done, fail) {
fulfill = function (fulfillmentValue) {
if (resolved) {return;}
......@@ -793,13 +816,7 @@ define("rsvp/queue",
};
}, canceller);
promise_list.push(resolve());
promise_list.push(promise_list[0].then(function () {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill();
}
}));
checkPromise(resolve(thenable));
queue.cancel = function () {
if (resolved) {return;}
......@@ -822,25 +839,9 @@ define("rsvp/queue",
throw new ResolvedQueueError();
}
next_promise = last_promise.then(done, fail);
promise_list.push(next_promise);
// Handle pop
promise_list.push(next_promise.then(function (fulfillmentValue) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
fulfill(fulfillmentValue);
} else {
return fulfillmentValue;
}
}, function (rejectedReason) {
promise_list.splice(0, 2);
if (promise_list.length === 0) {
reject(rejectedReason);
} else {
throw rejectedReason;
}
}));
checkPromise(last_promise.then(done, fail));
return this;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment