Skip to content

Commit f851e9c

Browse files
committed
refactor(system): rename startTrackDependencies, endTrackDependencies to startTrack, endTrack
1 parent da63619 commit f851e9c

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/computed.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ export class Computed<T = any> implements IComputed {
4747
}
4848

4949
update() {
50-
const prevSub = Subscriber.startTrackDependencies(this);
50+
const prevSub = Subscriber.startTrack(this);
5151
const oldValue = this.cachedValue;
5252
let newValue: T;
5353
try {
5454
newValue = this.getter(oldValue);
5555
} finally {
56-
Subscriber.endTrackDependencies(this, prevSub);
56+
Subscriber.endTrack(this, prevSub);
5757
}
5858
if (oldValue !== newValue) {
5959
this.cachedValue = newValue;

src/effect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export class Effect<T = any> implements IEffect {
5555
}
5656

5757
run() {
58-
const prevSub = Subscriber.startTrackDependencies(this);
58+
const prevSub = Subscriber.startTrack(this);
5959
try {
6060
return this.fn();
6161
} finally {
62-
Subscriber.endTrackDependencies(this, prevSub);
62+
Subscriber.endTrack(this, prevSub);
6363
}
6464
}
6565

src/system.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,21 @@ export namespace Subscriber {
392392
} while (true);
393393
}
394394

395+
/**
396+
* @deprecated Use `startTrack` instead.
397+
*/
395398
export function startTrackDependencies(sub: IComputed | IEffect) {
399+
return startTrack(sub);
400+
}
401+
402+
/**
403+
* @deprecated Use `endTrack` instead.
404+
*/
405+
export function endTrackDependencies(sub: IComputed | IEffect, prevSub: IComputed | IEffect | undefined) {
406+
return endTrack(sub, prevSub);
407+
}
408+
409+
export function startTrack(sub: IComputed | IEffect) {
396410
const newTrackId = system.lastTrackId + 1;
397411
const prevSub = system.activeSub;
398412

@@ -407,7 +421,7 @@ export namespace Subscriber {
407421
return prevSub;
408422
}
409423

410-
export function endTrackDependencies(sub: IComputed | IEffect, prevSub: IComputed | IEffect | undefined) {
424+
export function endTrack(sub: IComputed | IEffect, prevSub: IComputed | IEffect | undefined) {
411425
if (prevSub !== undefined) {
412426
system.activeSub = prevSub;
413427
system.activeTrackId = prevSub.trackId;

0 commit comments

Comments
 (0)