diff --git a/public/src/app.js b/public/src/app.js index 53d60ffe32..ed504fa00d 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -130,6 +130,20 @@ app.cacheBuster = null; }); }; + app.require = async (modules) => { // allows you to await require.js modules + let single = false; + if (!Array.isArray(modules)) { + modules = [modules]; + single = true; + } + + return new Promise((resolve, reject) => { + require(modules, (...exports) => { + resolve(single ? exports.pop() : exports); + }, reject); + }); + }; + app.logout = function (redirect) { redirect = redirect === undefined ? true : redirect; $(window).trigger('action:app.logout');