mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 20:46:01 +00:00
fixed race conditions when starting app
This commit is contained in:
22
packages/web/src/utility/appLoadManager.ts
Normal file
22
packages/web/src/utility/appLoadManager.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
let appIsLoaded = false;
|
||||
let onLoad = [];
|
||||
|
||||
export function setAppLoaded() {
|
||||
appIsLoaded = true;
|
||||
for (const func of onLoad) {
|
||||
func();
|
||||
}
|
||||
onLoad = [];
|
||||
}
|
||||
|
||||
export function getAppLoaded() {
|
||||
return appIsLoaded;
|
||||
}
|
||||
|
||||
export function callWhenAppLoaded(callback) {
|
||||
if (appIsLoaded) {
|
||||
callback();
|
||||
} else {
|
||||
onLoad.push(callback);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user