11import { createReactiveSystem , ReactiveFlags , type ReactiveNode } from './system.js' ;
22
3- interface Effect extends ReactiveNode {
3+ interface EffectNode extends ReactiveNode {
44 fn ( ) : void ;
55}
66
7- interface Computed < T = any > extends ReactiveNode {
7+ interface ComputedNode < T = any > extends ReactiveNode {
88 value : T | undefined ;
99 getter : ( previousValue ?: T ) => T ;
1010}
1111
12- interface Signal < T = any > extends ReactiveNode {
12+ interface SignalNode < T = any > extends ReactiveNode {
1313 currentValue : T ;
1414 pendingValue : T ;
1515}
@@ -20,29 +20,29 @@ let notifyIndex = 0;
2020let queuedLength = 0 ;
2121let activeSub : ReactiveNode | undefined ;
2222
23- const queued : ( Effect | undefined ) [ ] = [ ] ;
23+ const queued : ( EffectNode | undefined ) [ ] = [ ] ;
2424const {
2525 link,
2626 unlink,
2727 propagate,
2828 checkDirty,
2929 shallowPropagate,
3030} = createReactiveSystem ( {
31- update ( node : Signal | Computed ) : boolean {
31+ update ( node : SignalNode | ComputedNode ) : boolean {
3232 if ( node . depsTail !== undefined ) {
33- return updateComputed ( node as Computed ) ;
33+ return updateComputed ( node as ComputedNode ) ;
3434 } else {
35- return updateSignal ( node as Signal ) ;
35+ return updateSignal ( node as SignalNode ) ;
3636 }
3737 } ,
38- notify ( effect : Effect ) {
38+ notify ( effect : EffectNode ) {
3939 let insertIndex = queuedLength ;
4040 let firstInsertedIndex = insertIndex ;
4141
4242 do {
4343 effect . flags &= ~ ReactiveFlags . Watching ;
4444 queued [ insertIndex ++ ] = effect ;
45- effect = effect . subs ?. sub as Effect ;
45+ effect = effect . subs ?. sub as EffectNode ;
4646 if ( effect === undefined || ! ( effect . flags & ReactiveFlags . Watching ) ) {
4747 break ;
4848 }
@@ -141,7 +141,7 @@ export function computed<T>(getter: (previousValue?: T) => T): () => T {
141141}
142142
143143export function effect ( fn : ( ) => void ) : ( ) => void {
144- const e : Effect = {
144+ const e : EffectNode = {
145145 fn,
146146 subs : undefined ,
147147 subsTail : undefined ,
@@ -208,7 +208,7 @@ export function trigger(fn: () => void) {
208208 }
209209}
210210
211- function updateComputed ( c : Computed ) : boolean {
211+ function updateComputed ( c : ComputedNode ) : boolean {
212212 ++ cycle ;
213213 c . depsTail = undefined ;
214214 c . flags = ReactiveFlags . Mutable | ReactiveFlags . RecursedCheck ;
@@ -223,12 +223,12 @@ function updateComputed(c: Computed): boolean {
223223 }
224224}
225225
226- function updateSignal ( s : Signal ) : boolean {
226+ function updateSignal ( s : SignalNode ) : boolean {
227227 s . flags = ReactiveFlags . Mutable ;
228228 return s . currentValue !== ( s . currentValue = s . pendingValue ) ;
229229}
230230
231- function run ( e : Effect ) : void {
231+ function run ( e : EffectNode ) : void {
232232 const flags = e . flags ;
233233 if (
234234 flags & ReactiveFlags . Dirty
@@ -242,7 +242,7 @@ function run(e: Effect): void {
242242 e . flags = ReactiveFlags . Watching | ReactiveFlags . RecursedCheck ;
243243 const prevSub = setActiveSub ( e ) ;
244244 try {
245- ( e as Effect ) . fn ( ) ;
245+ ( e as EffectNode ) . fn ( ) ;
246246 } finally {
247247 activeSub = prevSub ;
248248 e . flags &= ~ ReactiveFlags . RecursedCheck ;
@@ -263,7 +263,7 @@ function flush(): void {
263263 queuedLength = 0 ;
264264}
265265
266- function computedOper < T > ( this : Computed < T > ) : T {
266+ function computedOper < T > ( this : ComputedNode < T > ) : T {
267267 const flags = this . flags ;
268268 if (
269269 flags & ReactiveFlags . Dirty
@@ -298,7 +298,7 @@ function computedOper<T>(this: Computed<T>): T {
298298 return this . value ! ;
299299}
300300
301- function signalOper < T > ( this : Signal < T > , ...value : [ T ] ) : T | void {
301+ function signalOper < T > ( this : SignalNode < T > , ...value : [ T ] ) : T | void {
302302 if ( value . length ) {
303303 if ( this . pendingValue !== ( this . pendingValue = value [ 0 ] ) ) {
304304 this . flags = ReactiveFlags . Mutable | ReactiveFlags . Dirty ;
@@ -331,7 +331,7 @@ function signalOper<T>(this: Signal<T>, ...value: [T]): T | void {
331331 }
332332}
333333
334- function effectOper ( this : Effect ) : void {
334+ function effectOper ( this : EffectNode ) : void {
335335 effectScopeOper . call ( this ) ;
336336}
337337
0 commit comments