@@ -49,8 +49,10 @@ const {
4949 toRemove = unlink ( toRemove , node ) ;
5050 } while ( toRemove !== undefined ) ;
5151 }
52- } else if ( ! ( 'previousValue ' in node ) ) {
52+ } else if ( 'fn ' in node ) {
5353 effectOper . call ( node ) ;
54+ } else if ( ! ( 'previousValue' in node ) ) {
55+ effectScopeOper . call ( node ) ;
5456 }
5557 } ,
5658} ) ;
@@ -84,6 +86,22 @@ export function endBatch() {
8486 }
8587}
8688
89+ export function isSignal ( fn : ( ) => void ) : boolean {
90+ return fn . name === 'bound signalOper' ;
91+ }
92+
93+ export function isComputed ( fn : ( ) => void ) : boolean {
94+ return fn . name === 'bound computedOper' ;
95+ }
96+
97+ export function isEffect ( fn : ( ) => void ) : boolean {
98+ return fn . name === 'bound effectOper' ;
99+ }
100+
101+ export function isEffectScope ( fn : ( ) => void ) : boolean {
102+ return fn . name === 'bound effectScopeOper' ;
103+ }
104+
87105export function signal < T > ( ) : {
88106 ( ) : T | undefined ;
89107 ( value : T | undefined ) : void ;
@@ -155,7 +173,7 @@ export function effectScope(fn: () => void): () => void {
155173 } finally {
156174 setCurrentSub ( prev ) ;
157175 }
158- return effectOper . bind ( e ) ;
176+ return effectScopeOper . bind ( e ) ;
159177}
160178
161179function updateComputed ( c : Computed ) : boolean {
@@ -281,7 +299,12 @@ function signalOper<T>(this: Signal<T>, ...value: [T]): T | void {
281299 }
282300}
283301
284- function effectOper ( this : Effect | EffectScope ) : void {
302+ function effectOper ( this : Effect ) : void {
303+ effectScopeOper . call ( this ) ;
304+ this . flags = 0 satisfies ReactiveFlags . None ;
305+ }
306+
307+ function effectScopeOper ( this : EffectScope ) : void {
285308 let dep = this . deps ;
286309 while ( dep !== undefined ) {
287310 dep = unlink ( dep , this ) ;
@@ -290,5 +313,4 @@ function effectOper(this: Effect | EffectScope): void {
290313 if ( sub !== undefined ) {
291314 unlink ( sub ) ;
292315 }
293- this . flags = 0 satisfies ReactiveFlags . None ;
294316}
0 commit comments