blob: 4b32f9527f5376093ffe2c424ed5e3cd7d30dedf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
// SPDX-FileCopyrightText: 2021 Evan Welsh <contact@evanwelsh.com>
// This example demonstrates that Promises always execute prior
// to timeouts. It should log "hello" then "world".
import GLib from 'gi://GLib';
const loop = GLib.MainLoop.new(null, false);
const promise = new Promise(r => {
let i = 100;
while (i--)
;
r();
});
setTimeout(() => {
promise.then(() => log('hello'));
});
setTimeout(() => {
log('world');
});
loop.run();
|