|
|
@@ -1,18 +1,20 @@
|
|
|
import { invokeArrayFns } from '@vue/shared'
|
|
|
import type { VaporLifecycleHooks } from './apiLifecycle'
|
|
|
import { type ComponentInternalInstance, setCurrentInstance } from './component'
|
|
|
-import { queuePostRenderEffect } from './scheduler'
|
|
|
+import { queuePostFlushCb } from './scheduler'
|
|
|
import { type DirectiveHookName, invokeDirectiveHook } from './directives'
|
|
|
|
|
|
export function invokeLifecycle(
|
|
|
instance: ComponentInternalInstance,
|
|
|
lifecycle: VaporLifecycleHooks,
|
|
|
directive: DirectiveHookName,
|
|
|
+ cb?: (instance: ComponentInternalInstance) => void,
|
|
|
post?: boolean,
|
|
|
) {
|
|
|
invokeArrayFns(post ? [invokeSub, invokeCurrent] : [invokeCurrent, invokeSub])
|
|
|
|
|
|
function invokeCurrent() {
|
|
|
+ cb && cb(instance)
|
|
|
const hooks = instance[lifecycle]
|
|
|
if (hooks) {
|
|
|
const fn = () => {
|
|
|
@@ -20,7 +22,7 @@ export function invokeLifecycle(
|
|
|
instance.scope.run(() => invokeArrayFns(hooks))
|
|
|
reset()
|
|
|
}
|
|
|
- post ? queuePostRenderEffect(fn) : fn()
|
|
|
+ post ? queuePostFlushCb(fn) : fn()
|
|
|
}
|
|
|
|
|
|
invokeDirectiveHook(instance, directive)
|
|
|
@@ -28,7 +30,7 @@ export function invokeLifecycle(
|
|
|
|
|
|
function invokeSub() {
|
|
|
instance.comps.forEach(comp =>
|
|
|
- invokeLifecycle(comp, lifecycle, directive, post),
|
|
|
+ invokeLifecycle(comp, lifecycle, directive, cb, post),
|
|
|
)
|
|
|
}
|
|
|
}
|