refactor(devtools): extract same logic into createDevtoolsHook
(#1608)
This commit is contained in:
parent
2c3427413d
commit
a8966457d3
@ -47,32 +47,24 @@ export function appUnmounted(app: App) {
|
|||||||
devtools.emit(DevtoolsHooks.APP_UNMOUNT, app)
|
devtools.emit(DevtoolsHooks.APP_UNMOUNT, app)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function componentAdded(component: ComponentInternalInstance) {
|
export const componentAdded = createDevtoolsHook(DevtoolsHooks.COMPONENT_ADDED)
|
||||||
if (!devtools || !component.appContext.__app) return
|
|
||||||
devtools.emit(
|
|
||||||
DevtoolsHooks.COMPONENT_ADDED,
|
|
||||||
component.appContext.__app,
|
|
||||||
component.uid,
|
|
||||||
component.parent ? component.parent.uid : undefined
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function componentUpdated(component: ComponentInternalInstance) {
|
export const componentUpdated = createDevtoolsHook(
|
||||||
if (!devtools || !component.appContext.__app) return
|
DevtoolsHooks.COMPONENT_UPDATED
|
||||||
devtools.emit(
|
)
|
||||||
DevtoolsHooks.COMPONENT_UPDATED,
|
|
||||||
component.appContext.__app,
|
|
||||||
component.uid,
|
|
||||||
component.parent ? component.parent.uid : undefined
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function componentRemoved(component: ComponentInternalInstance) {
|
export const componentRemoved = createDevtoolsHook(
|
||||||
if (!devtools || !component.appContext.__app) return
|
DevtoolsHooks.COMPONENT_REMOVED
|
||||||
devtools.emit(
|
)
|
||||||
DevtoolsHooks.COMPONENT_REMOVED,
|
|
||||||
component.appContext.__app,
|
function createDevtoolsHook(hook: DevtoolsHooks) {
|
||||||
component.uid,
|
return (component: ComponentInternalInstance) => {
|
||||||
component.parent ? component.parent.uid : undefined
|
if (!devtools || !component.appContext.__app) return
|
||||||
)
|
devtools.emit(
|
||||||
|
hook,
|
||||||
|
component.appContext.__app,
|
||||||
|
component.uid,
|
||||||
|
component.parent ? component.parent.uid : undefined
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user