summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-03-01 15:01:15 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit928af2b51fca5f3e120fbd7f74b77c27a104ba6a (patch)
tree662584833ce5e61ff96f5eb37bdb94a3c5b71947 /addons/web/static/src/js/services
parent979d82abe8e9458e9d31d0f0fb54c446e8abefe3 (diff)
[IMP] web: ajax service: ensure widget is alive
... before resolving/rejecting the deferred once the RPC is done. Doing this in the ajax service is equal to wrap every rpc with this.alive() in the former versions.
Diffstat (limited to 'addons/web/static/src/js/services')
-rw-r--r--addons/web/static/src/js/services/ajax_service.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/addons/web/static/src/js/services/ajax_service.js b/addons/web/static/src/js/services/ajax_service.js
index dbcd851e203..480549347d4 100644
--- a/addons/web/static/src/js/services/ajax_service.js
+++ b/addons/web/static/src/js/services/ajax_service.js
@@ -6,8 +6,18 @@ var session = require('web.session');
var AjaxService = AbstractService.extend({
name: 'ajax',
- rpc: function (route, args, options) {
- return session.rpc(route, args, options);
+ rpc: function (route, args, options, target) {
+ return $.Deferred(function (def) {
+ session.rpc(route, args, options).then(function () {
+ if (!target.isDestroyed()) {
+ def.resolve.apply(def, arguments);
+ }
+ }, function () {
+ if (!target.isDestroyed()) {
+ def.reject.apply(def, arguments);
+ }
+ });
+ }).promise();
},
});