refactor(reactivity): optimize child effect scope dereferencing (#4184)

This commit is contained in:
Bas van Meurs
2021-07-29 16:26:24 +02:00
committed by GitHub
parent 3b38c9ae9b
commit 91f29540fe
2 changed files with 37 additions and 14 deletions

View File

@@ -77,8 +77,9 @@ describe('reactivity/effect/scope', () => {
})
})
expect(scope.effects.length).toBe(2)
expect(scope.effects[1]).toBeInstanceOf(EffectScope)
expect(scope.effects.length).toBe(1)
expect(scope.scopes.length).toBe(1)
expect(scope.scopes[0]).toBeInstanceOf(EffectScope)
expect(dummy).toBe(0)
counter.num = 7
@@ -194,9 +195,9 @@ describe('reactivity/effect/scope', () => {
it('should derefence child scope from parent scope after stopping child scope (no memleaks)', async () => {
const parent = new EffectScope()
const child = parent.run(() => new EffectScope())!
expect(parent.effects.includes(child)).toBe(true)
expect(parent.scopes.includes(child)).toBe(true)
child.stop()
expect(parent.effects.includes(child)).toBe(false)
expect(parent.scopes.includes(child)).toBe(false)
})
it('test with higher level APIs', async () => {