From 29726e8fd000cb09075f9b6b2a6a8d2ddaf4ef58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 23 Aug 2019 13:19:24 +0000 Subject: [ADD] web: add owl 1.0.0-beta1 to odoo With this commit, we properly introduce the Owl library into our beloved codebase. More information on the Owl library can be found in the project repository: https://github.com/odoo/owl/ Co-authored-by: Aaron Bohy Co-authored-by: Julien Mougenot Co-authored-by: Mathieu Duckerts-Antoine --- addons/web/static/src/js/component_extension.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 addons/web/static/src/js/component_extension.js (limited to 'addons/web/static/src/js/component_extension.js') diff --git a/addons/web/static/src/js/component_extension.js b/addons/web/static/src/js/component_extension.js new file mode 100644 index 00000000000..39568bd0594 --- /dev/null +++ b/addons/web/static/src/js/component_extension.js @@ -0,0 +1,21 @@ +/** + * Add a new method to owl Components to ensure that no performed RPC is + * resolved/rejected when the component is destroyed. + */ +(function () { + owl.Component.prototype.rpc = function () { + return new Promise((resolve, reject) => { + return this.env.services.rpc(...arguments) + .then(result => { + if (!this.__owl__.isDestroyed) { + resolve(result); + } + }) + .catch(reason => { + if (!this.__owl__.isDestroyed) { + reject(reason); + } + }); + }); + }; +})(); -- cgit v1.2.3