]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(devtools): fix devtools attach
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 4 May 2021 16:48:35 +0000 (18:48 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 4 May 2021 16:52:25 +0000 (18:52 +0200)
src/rootStore.ts

index 419615eaf5f8a940f540fffff9fe623ae6830782..b529b3a53758b58ea5605bf81c155fa8e0250ef3 100644 (file)
@@ -65,7 +65,14 @@ export const storesMap = new WeakMap<
  */
 let clientAppPromise: Promise<App> | undefined
 let resolveApp: ((app: App) => void) | undefined
-export const setClientApp = (app: App) => resolveApp && resolveApp(app)
+export const setClientApp = (app: App) => {
+  if (resolveApp) {
+    resolveApp(app)
+  } else {
+    // setClientApp might be called before getClientApp
+    clientAppPromise = Promise.resolve(app)
+  }
+}
 export const getClientApp = () =>
   clientAppPromise ||
   (clientAppPromise = new Promise((resolve) => (resolveApp = resolve)))