Skip to content

Commit

Permalink
chore(reactivity): effectScope.ts variable declarations optimized and…
Browse files Browse the repository at this point in the history
… remove useless code in effect.ts (#11721)

* chore(reactivity): effectScope.ts variable declarations optimized and remove useless code in effect.ts

* fix(reactivity): batchDepth count error fixed

* fix(reactivity): batchDepth count error fixed

* chore(reactivity): modify the batchDepth increase type
  • Loading branch information
heggria committed Aug 28, 2024
1 parent 47d8158 commit 64e1ca2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,10 @@ export function startBatch(): void {
* @internal
*/
export function endBatch(): void {
if (batchDepth > 1) {
batchDepth--
if (--batchDepth > 0) {
return
}

batchDepth--
let error: unknown
while (batchedEffect) {
let e: ReactiveEffect | undefined = batchedEffect
Expand Down
10 changes: 6 additions & 4 deletions packages/reactivity/src/effectScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export class EffectScope {
pause(): void {
if (this._active) {
this._isPaused = true
let i, l
if (this.scopes) {
for (let i = 0, l = this.scopes.length; i < l; i++) {
for (i = 0, l = this.scopes.length; i < l; i++) {
this.scopes[i].pause()
}
}
for (let i = 0, l = this.effects.length; i < l; i++) {
for (i = 0, l = this.effects.length; i < l; i++) {
this.effects[i].pause()
}
}
Expand All @@ -71,12 +72,13 @@ export class EffectScope {
if (this._active) {
if (this._isPaused) {
this._isPaused = false
let i, l
if (this.scopes) {
for (let i = 0, l = this.scopes.length; i < l; i++) {
for (i = 0, l = this.scopes.length; i < l; i++) {
this.scopes[i].resume()
}
}
for (let i = 0, l = this.effects.length; i < l; i++) {
for (i = 0, l = this.effects.length; i < l; i++) {
this.effects[i].resume()
}
}
Expand Down

0 comments on commit 64e1ca2

Please sign in to comment.