Skip to content

Commit 1f63cf6

Browse files
committed
effectScope scopes doubly-linked list
1 parent a0b78f6 commit 1f63cf6

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export class EffectScope {
4444
constructor(public detached = false) {
4545
this.parent = activeEffectScope
4646
if (!detached && activeEffectScope) {
47-
if(activeEffectScope.scopesTail) {
47+
if (activeEffectScope.scopesTail) {
4848
this.prevEffectScope = activeEffectScope.scopesTail;
4949
activeEffectScope.scopesTail.nextEffectScope = this;
5050
activeEffectScope.scopesTail = this;
51-
}else {
51+
} else {
5252
activeEffectScope.scopes = activeEffectScope.scopesTail = this;
5353
}
5454
}
@@ -61,11 +61,10 @@ export class EffectScope {
6161
pause(): void {
6262
if (this._active) {
6363
this._isPaused = true
64-
let i, l
65-
for(let child = this.scopes; child != undefined; child = child.nextEffectScope) {
64+
for (let child = this.scopes; child != undefined; child = child.nextEffectScope) {
6665
child.pause();
6766
}
68-
for (i = 0, l = this.effects.length; i < l; i++) {
67+
for (let i = 0, l = this.effects.length; i < l; i++) {
6968
this.effects[i].pause()
7069
}
7170
}
@@ -78,11 +77,10 @@ export class EffectScope {
7877
if (this._active) {
7978
if (this._isPaused) {
8079
this._isPaused = false
81-
let i, l
82-
for(let child = this.scopes; child != undefined; child = child.nextEffectScope) {
80+
for (let child = this.scopes; child != undefined; child = child.nextEffectScope) {
8381
child.resume();
8482
}
85-
for (i = 0, l = this.effects.length; i < l; i++) {
83+
for (let i = 0, l = this.effects.length; i < l; i++) {
8684
this.effects[i].resume()
8785
}
8886
}
@@ -140,23 +138,23 @@ export class EffectScope {
140138
}
141139
this.cleanups.length = 0
142140

143-
for(let child = this.scopes; child != undefined; child = child.nextEffectScope) {
144-
child.stop();
141+
for (let child = this.scopes; child != undefined; child = child.nextEffectScope) {
142+
child.stop(true);
145143
}
146144
this.scopes = this.scopesTail = undefined;
147145

148146
// nested scope, dereference from parent to avoid memory leaks
149147
if (!this.detached && this.parent && !fromParent) {
150-
if(this.prevEffectScope) {
148+
if (this.prevEffectScope) {
151149
this.prevEffectScope.nextEffectScope = this.nextEffectScope;
152150
}
153-
if(this.nextEffectScope) {
151+
if (this.nextEffectScope) {
154152
this.nextEffectScope.prevEffectScope = this.prevEffectScope;
155153
}
156-
if(this.parent.scopes == this) {
154+
if (this.parent.scopes == this) {
157155
this.parent.scopes = this.nextEffectScope;
158156
}
159-
if(this.parent.scopesTail == this) {
157+
if (this.parent.scopesTail == this) {
160158
this.parent.scopesTail = this.prevEffectScope;
161159
}
162160
}

0 commit comments

Comments
 (0)