Skip to content

Commit

Permalink
fix(devtools): fix devtools attach
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 4, 2021
1 parent 1bcc41f commit 017795a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/rootStore.ts
Expand Up @@ -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)))
Expand Down

0 comments on commit 017795a

Please sign in to comment.