1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.signalToPromise = void 0;
|
8 | const coreutils_1 = require("@lumino/coreutils");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | function signalToPromise(signal, timeout) {
|
18 | const waitForSignal = new coreutils_1.PromiseDelegate();
|
19 | function cleanup() {
|
20 | signal.disconnect(slot);
|
21 | }
|
22 | function slot(sender, args) {
|
23 | cleanup();
|
24 | waitForSignal.resolve([sender, args]);
|
25 | }
|
26 | signal.connect(slot);
|
27 | if ((timeout !== null && timeout !== void 0 ? timeout : 0) > 0) {
|
28 | setTimeout(() => {
|
29 | cleanup();
|
30 | waitForSignal.reject(`Signal not emitted within ${timeout} ms.`);
|
31 | }, timeout);
|
32 | }
|
33 | return waitForSignal.promise;
|
34 | }
|
35 | exports.signalToPromise = signalToPromise;
|
36 |
|
\ | No newline at end of file |