Skip to content

Commit

Permalink
MaybeDirty_Recurse -> MaybeDirty_ComputedSideEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 29, 2024
1 parent 8d5bea5 commit 99f044e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/reactivity/__tests__/computed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)', () => {
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions packages/reactivity/src/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export class ComputedRefImpl<T> {
() => {
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)
}
Expand All @@ -69,8 +69,8 @@ export class ComputedRefImpl<T> {
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
}
Expand Down
2 changes: 1 addition & 1 deletion packages/reactivity/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export enum ReactiveFlags {
export enum DirtyLevels {
NotDirty = 0,
QueryingDirty = 1,
MaybeDirty_Recurse = 2,
MaybeDirty_ComputedSideEffect = 2,
MaybeDirty = 3,
Dirty = 4,
}
4 changes: 2 additions & 2 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ReactiveEffect<T = any> {

public get dirty() {
if (
this._dirtyLevel === DirtyLevels.MaybeDirty_Recurse ||
this._dirtyLevel === DirtyLevels.MaybeDirty_ComputedSideEffect ||
this._dirtyLevel === DirtyLevels.MaybeDirty
) {
this._dirtyLevel = DirtyLevels.QueryingDirty
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 99f044e

Please sign in to comment.