Skip to content

Commit 8339674

Browse files
committed
refactor(system): compatible with consumers that do not support inner effects
1 parent ca73a93 commit 8339674

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/effect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function effect(fn: () => void): Effect<void> {
77
return e;
88
}
99

10-
export class Effect<T = any> implements IEffect {
10+
export class Effect<T = any> implements IEffect, Dependency {
1111
nextNotify: IEffect | undefined = undefined;
1212

1313
// Dependency

src/system.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface IEffect extends Dependency, Subscriber {
1+
export interface IEffect extends Subscriber {
22
nextNotify: IEffect | undefined;
33
notify(): void;
44
}
@@ -21,7 +21,7 @@ export interface Subscriber {
2121
}
2222

2323
export interface Link {
24-
dep: Dependency | IComputed | IEffect;
24+
dep: Dependency | IComputed | (Dependency & IEffect);
2525
sub: Subscriber | IComputed | IEffect;
2626
trackId: number;
2727
// Also used as prev update
@@ -336,7 +336,7 @@ export namespace Subscriber {
336336

337337
if (sub.dirtyLevel === DirtyLevels.Dirty) {
338338
if (remaining !== 0) {
339-
const subSubs = sub.subs!;
339+
const subSubs = (sub as IComputed).subs!;
340340
const prevLink = subSubs.prevSub!;
341341
(sub as IComputed).update();
342342
subSubs.prevSub = undefined;
@@ -360,7 +360,7 @@ export namespace Subscriber {
360360
if (dirtyLevel === DirtyLevels.MaybeDirty) {
361361
sub.dirtyLevel = DirtyLevels.None;
362362
if (remaining !== 0) {
363-
const subSubs = sub.subs!;
363+
const subSubs = (sub as IComputed).subs!;
364364
const prevLink = subSubs.prevSub!;
365365
subSubs.prevSub = undefined;
366366
sub = prevLink.sub as IComputed | IEffect;
@@ -372,7 +372,7 @@ export namespace Subscriber {
372372
if (dirtyLevel === DirtyLevels.Dirty) {
373373
(sub as IComputed).update();
374374
}
375-
const subSubs = sub.subs!;
375+
const subSubs = (sub as IComputed).subs!;
376376
const prevLink = subSubs.prevSub!;
377377
subSubs.prevSub = undefined;
378378
sub = prevLink.sub as IComputed | IEffect;

0 commit comments

Comments
 (0)