diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2023-03-05 18:26:25 +0000 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2023-03-05 18:26:25 +0000 |
commit | ad36414e00d4d9c1b0160e1ec3041fd1607dcd77 (patch) | |
tree | b9ece2e1fda25100814480aaea1c21cf0701bdd4 /modules/esm/_timers.js | |
parent | 12de7257e2923c5285614d51f06d751ebc0c60a8 (diff) | |
parent | 52adc35e38b2475fd6468982bb9ed31d50304f36 (diff) | |
download | gjs-ad36414e00d4d9c1b0160e1ec3041fd1607dcd77.tar.gz |
Merge branch 'february-maintenance' into 'master'
February maintenance
See merge request GNOME/gjs!828
Diffstat (limited to 'modules/esm/_timers.js')
-rw-r--r-- | modules/esm/_timers.js | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/modules/esm/_timers.js b/modules/esm/_timers.js index 94da6f8f..ca20b71d 100644 --- a/modules/esm/_timers.js +++ b/modules/esm/_timers.js @@ -6,11 +6,6 @@ // Note: implicit coercion with + is used to perform the ToNumber algorithm from // the timers specification -import GLib from 'gi://GLib'; -import GObject from 'gi://GObject'; - -const PromiseNative = import.meta.importSync('_promiseNative'); - /** * @param {number} delay a number value (in milliseconds) */ @@ -52,9 +47,9 @@ function checkThis(thisArg) { * @returns {GLib.Source} */ function createTimeoutSource(timeout, handler) { - const source = GLib.timeout_source_new(timeout); - source.set_priority(GLib.PRIORITY_DEFAULT); - GObject.source_set_closure(source, handler); + const source = imports.gi.GLib.timeout_source_new(timeout); + source.set_priority(imports.gi.GLib.PRIORITY_DEFAULT); + imports.gi.GObject.source_set_closure(source, handler); return source; } @@ -72,13 +67,13 @@ function setTimeout(callback, delay = 0, ...args) { const boundCallback = callback.bind(globalThis, ...args); const source = createTimeoutSource(delay, () => { if (!timeouts.has(source)) - return GLib.SOURCE_REMOVE; + return imports.gi.GLib.SOURCE_REMOVE; boundCallback(); releaseSource(source); - PromiseNative.drainMicrotaskQueue(); + import.meta.importSync('_promiseNative').drainMicrotaskQueue(); - return GLib.SOURCE_REMOVE; + return imports.gi.GLib.SOURCE_REMOVE; }); addSource(source); @@ -98,12 +93,12 @@ function setInterval(callback, delay = 0, ...args) { const boundCallback = callback.bind(globalThis, ...args); const source = createTimeoutSource(delay, () => { if (!timeouts.has(source)) - return GLib.SOURCE_REMOVE; + return imports.gi.GLib.SOURCE_REMOVE; boundCallback(); - PromiseNative.drainMicrotaskQueue(); + import.meta.importSync('_promiseNative').drainMicrotaskQueue(); - return GLib.SOURCE_CONTINUE; + return imports.gi.GLib.SOURCE_CONTINUE; }); addSource(source); |