fixed race conditions when starting app

This commit is contained in:
Jan Prochazka
2021-05-17 17:42:53 +02:00
parent e44a95d723
commit 9d933d669a
4 changed files with 66 additions and 14 deletions

View 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);
}
}