feat(runtime-core): watchSyncEffect

This commit is contained in:
Evan You
2021-07-20 16:49:54 -04:00
parent 33c2fbfdc8
commit d87d059ac1
3 changed files with 64 additions and 3 deletions

View File

@@ -96,6 +96,19 @@ export function watchPostEffect(
)
}
export function watchSyncEffect(
effect: WatchEffect,
options?: DebuggerOptions
) {
return doWatch(
effect,
null,
(__DEV__
? Object.assign(options || {}, { flush: 'sync' })
: { flush: 'sync' }) as WatchOptionsBase
)
}
// initial value for watchers to trigger on undefined initial values
const INITIAL_WATCHER_VALUE = {}

View File

@@ -34,7 +34,12 @@ export {
getCurrentScope,
onScopeDispose
} from '@vue/reactivity'
export { watch, watchEffect, watchPostEffect } from './apiWatch'
export {
watch,
watchEffect,
watchPostEffect,
watchSyncEffect
} from './apiWatch'
export {
onBeforeMount,
onMounted,