Skip to content

Commit 09a5b4a

Browse files
committed
refactor(system): remove IEffectScope
1 parent 6a501c7 commit 09a5b4a

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/effectScope.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { DirtyLevels, IEffectScope, Link, Subscriber } from './system.js';
1+
import { DirtyLevels, IEffect, Link, Subscriber } from './system.js';
22

33
export function effectScope() {
44
return new EffectScope();
55
}
66

7-
export class EffectScope implements IEffectScope {
8-
nextNotify: IEffectScope | undefined = undefined;
7+
export class EffectScope implements IEffect {
8+
nextNotify: IEffect | undefined = undefined;
9+
10+
// Dependency
11+
subs: Link | undefined = undefined;
12+
subsTail: Link | undefined = undefined;
913

1014
// Subscriber
1115
deps: Link | undefined = undefined;

src/system.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
export interface IEffectScope extends Subscriber {
2-
nextNotify: IEffectScope | undefined;
1+
export interface IEffect extends Dependency, Subscriber {
2+
nextNotify: IEffect | undefined;
33
notify(): void;
44
}
55

6-
export interface IEffect extends Dependency, IEffectScope { }
7-
86
export interface IComputed extends Dependency, Subscriber {
97
update(): void;
108
}
@@ -24,7 +22,7 @@ export interface Subscriber {
2422

2523
export interface Link {
2624
dep: Dependency | IComputed | IEffect;
27-
sub: IComputed | IEffect | IEffectScope;
25+
sub: IComputed | IEffect;
2826
trackId: number;
2927
// Also used as prev update
3028
prevSub: Link | undefined;
@@ -43,13 +41,13 @@ export const enum DirtyLevels {
4341

4442
export namespace System {
4543
export let activeSub: IComputed | IEffect | undefined = undefined;
46-
export let activeEffectScope: IEffectScope | undefined = undefined;
44+
export let activeEffectScope: IEffect | undefined = undefined;
4745
export let activeTrackId = 0;
4846
export let activeEffectScopeTrackId = 0;
4947
export let batchDepth = 0;
5048
export let lastTrackId = 0;
51-
export let queuedEffects: IEffectScope | undefined = undefined;
52-
export let queuedEffectsTail: IEffectScope | undefined = undefined;
49+
export let queuedEffects: IEffect | undefined = undefined;
50+
export let queuedEffectsTail: IEffect | undefined = undefined;
5351
}
5452

5553
export function startBatch() {
@@ -433,7 +431,7 @@ export namespace Subscriber {
433431
sub.trackId = -sub.trackId;
434432
}
435433

436-
export function startTrackEffects(sub: IEffectScope) {
434+
export function startTrackEffects(sub: IEffect) {
437435
const newVersion = system.lastTrackId + 1;
438436
const prevSub = system.activeEffectScope;
439437

@@ -448,7 +446,7 @@ export namespace Subscriber {
448446
return prevSub;
449447
}
450448

451-
export function endTrackEffects(sub: IEffectScope, prevSub: IEffectScope | undefined) {
449+
export function endTrackEffects(sub: IEffect, prevSub: IEffect | undefined) {
452450
if (prevSub !== undefined) {
453451
system.activeEffectScope = prevSub;
454452
system.activeEffectScopeTrackId = prevSub.trackId;

0 commit comments

Comments
 (0)