summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2022-08-10 22:27:21 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2022-08-10 23:18:06 +0200
commit9828094d2cccd777001776086849397e038467b0 (patch)
tree3e5a5c1c7e7a31c328ca787638133896ceda7d00 /modules
parent3867a2f9b16f9fd4f86a8014ddc70607338a9309 (diff)
downloadgjs-9828094d2cccd777001776086849397e038467b0.tar.gz
Gio: Simplify init_async usage by always using a promise
The function is defined as a so we can just rely on promise syntax to handle the results.
Diffstat (limited to 'modules')
-rw-r--r--modules/core/overrides/Gio.js15
1 files changed, 2 insertions, 13 deletions
diff --git a/modules/core/overrides/Gio.js b/modules/core/overrides/Gio.js
index 1fab4796..becefa03 100644
--- a/modules/core/overrides/Gio.js
+++ b/modules/core/overrides/Gio.js
@@ -247,19 +247,8 @@ function _makeProxyWrapper(interfaceXml) {
if (!cancellable)
cancellable = null;
if (asyncCallback) {
- obj.init_async(GLib.PRIORITY_DEFAULT, cancellable, (initable, result) => {
- let caughtErrorWhenInitting = null;
- try {
- initable.init_finish(result);
- } catch (e) {
- caughtErrorWhenInitting = e;
- }
-
- if (caughtErrorWhenInitting === null)
- asyncCallback(initable, null);
- else
- asyncCallback(null, caughtErrorWhenInitting);
- });
+ obj.init_async(GLib.PRIORITY_DEFAULT, cancellable).then(
+ () => asyncCallback(obj, null)).catch(e => asyncCallback(null, e));
} else {
obj.init(cancellable);
}