fix(reactivity): ensure computed always expose value

fix #3099

Also changes the original fix for #910 by moving the fix from
reactivity to the scheduler
This commit is contained in:
Evan You
2021-05-27 20:53:21 -04:00
parent 32e21333dd
commit 03a7a73148
5 changed files with 52 additions and 42 deletions

View File

@@ -709,28 +709,6 @@ describe('reactivity/effect', () => {
expect(dummy).toBe(3)
})
it('stop with scheduler', () => {
let dummy
const obj = reactive({ prop: 1 })
const queue: (() => void)[] = []
const runner = effect(
() => {
dummy = obj.prop
},
{
scheduler: e => queue.push(e)
}
)
obj.prop = 2
expect(dummy).toBe(1)
expect(queue.length).toBe(1)
stop(runner)
// a scheduled effect should not execute anymore after stopped
queue.forEach(e => e())
expect(dummy).toBe(1)
})
it('events: onStop', () => {
const onStop = jest.fn()
const runner = effect(() => {}, {