Skip to content

Commit 0041ddc

Browse files
committed
refactor: make setActiveSub parameter optional
1 parent 69af377 commit 0041ddc

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function getActiveSub(): ReactiveNode | undefined {
7171
return activeSub;
7272
}
7373

74-
export function setActiveSub(sub: ReactiveNode | undefined) {
74+
export function setActiveSub(sub?: ReactiveNode) {
7575
const prevSub = activeSub;
7676
activeSub = sub;
7777
return prevSub;

tests/effect.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ test('should duplicate subscribers do not affect the notify order', () => {
184184

185185
effect(() => {
186186
order.push('a');
187-
const currentSub = setActiveSub(undefined);
187+
const currentSub = setActiveSub();
188188
const isOne = src2() === 1;
189189
setActiveSub(currentSub);
190190
if (isOne) {

tests/issue_48.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function reaction<T>(
8888
}
8989

9090
function untracked<T>(callback: () => T): T {
91-
const currentSub = setActiveSub(undefined);
91+
const currentSub = setActiveSub();
9292
try {
9393
return callback();
9494
} finally {

tests/untrack.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test('should pause tracking in computed', () => {
77
let computedTriggerTimes = 0;
88
const c = computed(() => {
99
computedTriggerTimes++;
10-
const currentSub = setActiveSub(undefined);
10+
const currentSub = setActiveSub();
1111
const value = src();
1212
setActiveSub(currentSub);
1313
return value;
@@ -29,7 +29,7 @@ test('should pause tracking in effect', () => {
2929
effect(() => {
3030
effectTriggerTimes++;
3131
if (is()) {
32-
const currentSub = setActiveSub(undefined);
32+
const currentSub = setActiveSub();
3333
src();
3434
setActiveSub(currentSub);
3535
}
@@ -63,7 +63,7 @@ test('should pause tracking in effect scope', () => {
6363
effectScope(() => {
6464
effect(() => {
6565
effectTriggerTimes++;
66-
const currentSub = setActiveSub(undefined);
66+
const currentSub = setActiveSub();
6767
src();
6868
setActiveSub(currentSub);
6969
});

0 commit comments

Comments
 (0)