File tree 1 file changed +25
-1
lines changed 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,17 @@ import {
9
9
isPlainObject ,
10
10
isSet ,
11
11
} from '@vue/shared'
12
+ import { Link } from 'alien-signals'
12
13
import type { ComputedRef } from './computed'
13
14
import { ReactiveFlags } from './constants'
14
15
import {
15
16
type DebuggerOptions ,
16
17
type EffectScheduler ,
17
18
ReactiveEffect ,
18
19
pauseTracking ,
19
- resetTracking
20
+ resetTracking ,
20
21
} from './effect'
22
+ import { getCurrentScope } from './effectScope'
21
23
import { isReactive , isShallow } from './reactive'
22
24
import { type Ref , isRef } from './ref'
23
25
import { warn } from './warning'
@@ -207,8 +209,30 @@ export function watch(
207
209
getter = ( ) => traverse ( baseGetter ( ) , depth )
208
210
}
209
211
212
+ const scope = getCurrentScope ( )
210
213
const watchHandle : WatchHandle = ( ) => {
211
214
effect . stop ( )
215
+ if ( scope ) {
216
+ let prevDep : Link | undefined
217
+ let link = scope . deps
218
+ while ( link !== undefined ) {
219
+ if ( link . dep === effect ) {
220
+ const nextDep = link . nextDep
221
+ if ( prevDep !== undefined ) {
222
+ prevDep . nextDep = nextDep
223
+ }
224
+ if ( nextDep === undefined ) {
225
+ scope . depsTail = prevDep
226
+ }
227
+ if ( prevDep === undefined ) {
228
+ scope . deps = nextDep
229
+ }
230
+ Link . release ( link )
231
+ break
232
+ }
233
+ link = link . nextDep
234
+ }
235
+ }
212
236
}
213
237
214
238
if ( once && cb ) {
You can’t perform that action at this time.
0 commit comments