From eefd8ed97203f084ccd9270bcd9be2dcac4dc62a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 29 Apr 2021 09:44:26 +0200 Subject: [PATCH] improve egw.langRequire to return a Promise, if no callback specified --- api/js/jsapi/egw_lang.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/js/jsapi/egw_lang.js b/api/js/jsapi/egw_lang.js index c3589b0d0c..6a6b96d877 100644 --- a/api/js/jsapi/egw_lang.js +++ b/api/js/jsapi/egw_lang.js @@ -133,6 +133,7 @@ egw.extend('lang', egw.MODULE_GLOBAL, function() * } * @param {function} _callback called after loading, if not given ready event will be postponed instead * @param {object} _context for callback + * @return Promise if no _callback specified */ langRequire: function(_window, _apps, _callback, _context) { // Get the ready and the files module for the given window @@ -171,10 +172,14 @@ egw.extend('lang', egw.MODULE_GLOBAL, function() // Require a "ready postpone token" var token = ready.readyWaitFor(); - // Call "readyDone" once all js files have been included. - files.includeJS(jss, function () { - ready.readyDone(token); - }, this); + return new Promise(function(resolve) + { + // Call "readyDone" once all js files have been included. + files.includeJS(jss, function () { + ready.readyDone(token); + resolve(); + }, this); + }); } } else if (typeof _callback == 'function')