File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,14 +88,34 @@ export const debug = <T extends Record<string, any>>(
8888 { immediate : true , deep : true } ,
8989 )
9090 } else {
91+ let stateScope :
92+ | ReturnType < typeof effectScope >
93+ | undefined
94+
9195 watch (
92- [ ( ) => toValue ( options . enable ) , ( ) => state ] ,
93- ( [ isActive ] ) => {
94- if ( isActive ) upsert ( entry )
95- else remove ( entry )
96+ ( ) => toValue ( options . enable ) ,
97+ ( isActive ) => {
98+ if ( isActive ) {
99+ stateScope = effectScope ( )
100+ stateScope . run ( ( ) => {
101+ watch (
102+ ( ) => state ,
103+ ( value ) => {
104+ upsert ( { ...entry , debugState : value } )
105+ } ,
106+ { immediate : true , deep : true } ,
107+ )
108+ } )
109+ } else {
110+ stateScope ?. stop ( )
111+ stateScope = undefined
112+ remove ( entry )
113+ }
96114 } ,
97- { immediate : true , deep : true } ,
115+ { immediate : true } ,
98116 )
117+
118+ onScopeDispose ( ( ) => stateScope ?. stop ( ) )
99119 }
100120 } )
101121
You can’t perform that action at this time.
0 commit comments