Skip to content

Commit d92c37a

Browse files
committed
refactor: simplify implementation
1 parent 043eb35 commit d92c37a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class EffectScope {
1111
/**
1212
* @internal track `on` calls, allow `on` call multiple times
1313
*/
14-
private _onCallCount = 0
14+
private _on = 0
1515
/**
1616
* @internal
1717
*/
@@ -109,8 +109,7 @@ export class EffectScope {
109109
* @internal
110110
*/
111111
on(): void {
112-
this._onCallCount++
113-
if (this._onCallCount === 1) {
112+
if (++this._on === 1) {
114113
this.prevScope = activeEffectScope
115114
activeEffectScope = this
116115
}
@@ -121,8 +120,7 @@ export class EffectScope {
121120
* @internal
122121
*/
123122
off(): void {
124-
this._onCallCount = Math.max(0, this._onCallCount - 1)
125-
if (this._onCallCount === 0) {
123+
if (this._on > 0 && --this._on === 0) {
126124
activeEffectScope = this.prevScope
127125
}
128126
}

0 commit comments

Comments
 (0)