From 99f044ea9d3c20edebd740450ae1a544c6eb38a8 Mon Sep 17 00:00:00 2001 From: Johnson Chu Date: Mon, 29 Jan 2024 19:51:09 +0800 Subject: [PATCH] MaybeDirty_Recurse -> MaybeDirty_ComputedSideEffect --- packages/reactivity/__tests__/computed.spec.ts | 8 ++++---- packages/reactivity/src/computed.ts | 8 ++++---- packages/reactivity/src/constants.ts | 2 +- packages/reactivity/src/effect.ts | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/reactivity/__tests__/computed.spec.ts b/packages/reactivity/__tests__/computed.spec.ts index 0d3984810db..b6c227a7b16 100644 --- a/packages/reactivity/__tests__/computed.spec.ts +++ b/packages/reactivity/__tests__/computed.spec.ts @@ -482,8 +482,8 @@ describe('reactivity/computed', () => { c3.value expect(c1.effect._dirtyLevel).toBe(DirtyLevels.Dirty) - expect(c2.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_Recurse) - expect(c3.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_Recurse) + expect(c2.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_ComputedSideEffect) + expect(c3.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_ComputedSideEffect) }) it('should work when chained(ref+computed)', () => { @@ -550,8 +550,8 @@ describe('reactivity/computed', () => { c3.value expect(c1.effect._dirtyLevel).toBe(DirtyLevels.Dirty) - expect(c2.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_Recurse) - expect(c3.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_Recurse) + expect(c2.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_ComputedSideEffect) + expect(c3.effect._dirtyLevel).toBe(DirtyLevels.MaybeDirty_ComputedSideEffect) v1.value.v.value = 999 expect(c1.effect._dirtyLevel).toBe(DirtyLevels.Dirty) diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index 4a7b67e18c1..09e98e42b4d 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -46,9 +46,9 @@ export class ComputedRefImpl { () => { if ( this.effect._runnings || - this.effect._dirtyLevel === DirtyLevels.MaybeDirty_Recurse + this.effect._dirtyLevel === DirtyLevels.MaybeDirty_ComputedSideEffect ) { - triggerRefValue(this, DirtyLevels.MaybeDirty_Recurse) + triggerRefValue(this, DirtyLevels.MaybeDirty_ComputedSideEffect) } else { triggerRefValue(this, DirtyLevels.MaybeDirty) } @@ -69,8 +69,8 @@ export class ComputedRefImpl { triggerRefValue(self, DirtyLevels.Dirty) } trackRefValue(self) - if (self.effect._dirtyLevel >= DirtyLevels.MaybeDirty_Recurse) { - triggerRefValue(self, DirtyLevels.MaybeDirty_Recurse) + if (self.effect._dirtyLevel >= DirtyLevels.MaybeDirty_ComputedSideEffect) { + triggerRefValue(self, DirtyLevels.MaybeDirty_ComputedSideEffect) } return self._value } diff --git a/packages/reactivity/src/constants.ts b/packages/reactivity/src/constants.ts index 62ffe717f10..baa75d61644 100644 --- a/packages/reactivity/src/constants.ts +++ b/packages/reactivity/src/constants.ts @@ -25,7 +25,7 @@ export enum ReactiveFlags { export enum DirtyLevels { NotDirty = 0, QueryingDirty = 1, - MaybeDirty_Recurse = 2, + MaybeDirty_ComputedSideEffect = 2, MaybeDirty = 3, Dirty = 4, } diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index 09ad8d2027f..ca90544c0de 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -77,7 +77,7 @@ export class ReactiveEffect { public get dirty() { if ( - this._dirtyLevel === DirtyLevels.MaybeDirty_Recurse || + this._dirtyLevel === DirtyLevels.MaybeDirty_ComputedSideEffect || this._dirtyLevel === DirtyLevels.MaybeDirty ) { this._dirtyLevel = DirtyLevels.QueryingDirty @@ -314,7 +314,7 @@ export function triggerEffects( effect.trigger() if ( (!effect._runnings || effect.allowRecurse) && - effect._dirtyLevel !== DirtyLevels.MaybeDirty_Recurse + effect._dirtyLevel !== DirtyLevels.MaybeDirty_ComputedSideEffect ) { effect._shouldSchedule = false if (effect.scheduler) {