Skip to content

Commit 61ca693

Browse files
committed
fix: improve connect flow
1 parent 908f9bf commit 61ca693

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/app-backend-core/src/app.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,7 @@ export function getAppRecordId (app): number {
106106
export function getAppRecord (app: any, ctx: BackendContext) {
107107
return ctx.appRecords.find(ar => ar.options.app === app)
108108
}
109+
110+
export function waitForAppsRegistration () {
111+
return jobs.queue(async () => { /* NOOP */ })
112+
}

packages/app-backend-core/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
} from './component'
2626
import { addQueuedPlugins, addPlugin, sendPluginList, addPreviouslyRegisteredPlugins } from './plugin'
2727
import { PluginDescriptor, SetupFunction, TimelineLayerOptions, App, TimelineEventOptions, CustomInspectorOptions } from '@vue/devtools-api'
28-
import { registerApp, selectApp, mapAppRecord, getAppRecordId } from './app'
28+
import { registerApp, selectApp, mapAppRecord, getAppRecordId, waitForAppsRegistration } from './app'
2929
import { sendInspectorTree, getInspector, getInspectorWithAppId, sendInspectorState } from './inspector'
3030
import { showScreenshot } from './timeline-screenshot'
3131

@@ -55,11 +55,11 @@ export async function initBackend (bridge: Bridge) {
5555
hook.once(HookEvents.INIT, connect)
5656
}
5757

58-
hook.on(HookEvents.APP_ADD, app => {
58+
hook.on(HookEvents.APP_ADD, async app => {
59+
await registerApp(app, ctx)
60+
5961
// Will init connect
6062
hook.emit(HookEvents.INIT)
61-
62-
registerApp(app, ctx)
6363
})
6464

6565
// In case we close and open devtools again
@@ -71,12 +71,16 @@ export async function initBackend (bridge: Bridge) {
7171
}
7272
}
7373

74-
function connect () {
74+
async function connect () {
7575
if (connected) {
7676
return
7777
}
7878
connected = true
7979

80+
await waitForAppsRegistration()
81+
82+
console.log('%cconnect', 'color: blue;')
83+
8084
ctx.currentTab = BuiltinTabs.COMPONENTS
8185

8286
// Subscriptions

0 commit comments

Comments
 (0)