forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunAfterActivation.ts
More file actions
31 lines (28 loc) · 807 Bytes
/
Copy pathrunAfterActivation.ts
File metadata and controls
31 lines (28 loc) · 807 Bytes
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
28
29
30
31
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const itemsToRun: (() => void)[] = [];
let activationCompleted = false;
/**
* Add items to be run after extension activation. This will add item
* to the end of the list. This function will immediately run the item
* if extension is already activated.
*/
export function addItemsToRunAfterActivation(run: () => void): void {
if (activationCompleted) {
run();
} else {
itemsToRun.push(run);
}
}
/**
* This should be called after extension activation is complete.
*/
export function runAfterActivation(): void {
activationCompleted = true;
while (itemsToRun.length > 0) {
const run = itemsToRun.shift();
if (run) {
run();
}
}
}