From: Eduardo San Martin Morote Date: Tue, 4 May 2021 16:48:35 +0000 (+0200) Subject: fix(devtools): fix devtools attach X-Git-Tag: v2.0.0-alpha.16~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8e6a9ec3f519fb14319e17598800fe64315c92e1;p=thirdparty%2Fvuejs%2Fpinia.git fix(devtools): fix devtools attach --- diff --git a/src/rootStore.ts b/src/rootStore.ts index 419615ea..b529b3a5 100644 --- a/src/rootStore.ts +++ b/src/rootStore.ts @@ -65,7 +65,14 @@ export const storesMap = new WeakMap< */ let clientAppPromise: Promise | 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)))