1234567891011121314151617181920212223242526272829 |
- import { watchEffect, watch, nextTick } from 'vue'
- export const useWatchOnly = (...args: Parameters<typeof watch>) => {
- const cbRaw = args[1]
- let stop
- args[1] = (...args) => {
- if (stop) {
- stop()
- } else {
- nextTick(stop)
- }
- return cbRaw(...args)
- }
- stop = watch(...args)
- }
- export const useWatchEffectOnly = (...args: Parameters<typeof watchEffect>) => {
- const cbRaw = args[0]
- let stop
- args[0] = (...args) => {
- if (stop) {
- stop()
- } else {
- nextTick(stop)
- }
- return cbRaw(...args)
- }
- stop = watchEffect(...args)
- }
|