Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disconnect when all apps are unmount #357

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/devtools-kit/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function initDevTools() {
},
]

if (devtoolsAppRecords.value.length === 1) {
if (devtoolsAppRecords.value.length >= 1) {
await setActiveAppRecord(devtoolsAppRecords.value[0])
devtoolsState.connected = true
devtoolsHooks.callHook(DevToolsHooks.APP_CONNECTED)
Expand All @@ -65,6 +65,11 @@ export function initDevTools() {

hook.on.vueAppUnmount(async (app) => {
const activeRecords = devtoolsAppRecords.value.filter(appRecord => appRecord.app !== app)
// #356 should disconnect when all apps are unmounted
if (activeRecords.length === 0) {
devtoolsState.connected = false
return
}
devtoolsAppRecords.value = activeRecords
if (devtoolsAppRecords.active.app === app)
await setActiveAppRecord(activeRecords[0])
Expand Down
8 changes: 5 additions & 3 deletions packages/playground/multi-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import 'uno.css'

const app = createApp(App)

const app2 = createApp(App2)

app.mount('#app')

app2.mount('#app2')
setTimeout(() => {
app.unmount()
app.mount('#app')
createApp(App2).mount('#app2')
}, 500)
Loading