Use Promise to wait for the extension manager
This commit is contained in:
+13
-12
@@ -60,7 +60,7 @@ function init() {
|
|||||||
* initialized before starting.
|
* initialized before starting.
|
||||||
*/
|
*/
|
||||||
function enable() {
|
function enable() {
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => _waitForExtensionManager(start));
|
_waitForExtensionManager().then(() => start());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,16 +118,17 @@ function disable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for the Extension Manager to be initialized and run a callback function.
|
* Wait for the Extension Manager to be initialized. Returns a Promise.
|
||||||
*
|
|
||||||
* @param {Function} callback The function to run when the Extension Manager
|
|
||||||
* is initialized.
|
|
||||||
*/
|
*/
|
||||||
function _waitForExtensionManager(callback) {
|
function _waitForExtensionManager() {
|
||||||
logDebug('Waiting for Extension Manager initialization...');
|
return new Promise(resolve => {
|
||||||
while (!compat.extensionManagerInitialized())
|
logDebug('Waiting for Extension Manager initialization...');
|
||||||
continue;
|
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||||
logDebug('Extension Manager initialized.');
|
while (!compat.extensionManagerInitialized())
|
||||||
callback();
|
continue;
|
||||||
return false;
|
return false;
|
||||||
|
});
|
||||||
|
logDebug('Extension Manager initialized.');
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user