mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: allow requirejs modules to be awaited
This commit is contained in:
@@ -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) {
|
app.logout = function (redirect) {
|
||||||
redirect = redirect === undefined ? true : redirect;
|
redirect = redirect === undefined ? true : redirect;
|
||||||
$(window).trigger('action:app.logout');
|
$(window).trigger('action:app.logout');
|
||||||
|
|||||||
Reference in New Issue
Block a user