fix(watch): ignore lazy option in simple watch (#546)
* fix(watch): ignore lazy option in simple watch * test: ignore lazy option in simple watch
This commit is contained in:
parent
c57837c324
commit
c2c9c2b57e
@ -344,6 +344,25 @@ describe('api: watch', () => {
|
|||||||
expect(cb).toHaveBeenCalled()
|
expect(cb).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('ignore lazy', async () => {
|
||||||
|
const count = ref(0)
|
||||||
|
let dummy
|
||||||
|
watch(
|
||||||
|
() => {
|
||||||
|
dummy = count.value
|
||||||
|
},
|
||||||
|
{ lazy: true }
|
||||||
|
)
|
||||||
|
expect(dummy).toBeUndefined()
|
||||||
|
|
||||||
|
await nextTick()
|
||||||
|
expect(dummy).toBe(0)
|
||||||
|
|
||||||
|
count.value++
|
||||||
|
await nextTick()
|
||||||
|
expect(dummy).toBe(1)
|
||||||
|
})
|
||||||
|
|
||||||
it('onTrack', async () => {
|
it('onTrack', async () => {
|
||||||
const events: DebuggerEvent[] = []
|
const events: DebuggerEvent[] = []
|
||||||
let dummy
|
let dummy
|
||||||
|
@ -197,7 +197,7 @@ function doWatch(
|
|||||||
scheduler: applyCb ? () => scheduler(applyCb) : scheduler
|
scheduler: applyCb ? () => scheduler(applyCb) : scheduler
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!lazy) {
|
if (!lazy || !cb) {
|
||||||
if (applyCb) {
|
if (applyCb) {
|
||||||
scheduler(applyCb)
|
scheduler(applyCb)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user