File tree 1 file changed +12
-22
lines changed
1 file changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import {
22
22
} from './effect'
23
23
import { isReactive , isShallow } from './reactive'
24
24
import { type Ref , isRef } from './ref'
25
- import { getCurrentScope } from './effectScope'
26
25
27
26
// These errors were transferred from `packages/runtime-core/src/errorHandling.ts`
28
27
// along with baseWatch to maintain code compatibility. Hence,
@@ -244,27 +243,18 @@ export function baseWatch(
244
243
}
245
244
246
245
if ( once ) {
247
- if ( ! cb ) {
248
- // onWatcherCleanup need use effect as a key
249
- getCurrentScope ( ) ?. effects . push ( ( effect = { } as any ) )
250
- getter ( )
251
- return
252
- }
253
- if ( immediate ) {
254
- // onWatcherCleanup need use effect as a key
255
- getCurrentScope ( ) ?. effects . push ( ( effect = { } as any ) )
256
- callWithAsyncErrorHandling (
257
- cb ,
258
- onError ,
259
- BaseWatchErrorCodes . WATCH_CALLBACK ,
260
- [ getter ( ) , isMultiSource ? [ ] : undefined , onWatcherCleanup ] ,
261
- )
262
- return
263
- }
264
- const _cb = cb
265
- cb = ( ...args ) => {
266
- _cb ( ...args )
267
- effect ?. stop ( )
246
+ if ( cb ) {
247
+ const _cb = cb
248
+ cb = ( ...args ) => {
249
+ _cb ( ...args )
250
+ effect ?. stop ( )
251
+ }
252
+ } else {
253
+ const _getter = getter
254
+ getter = ( ) => {
255
+ _getter ( )
256
+ effect ?. stop ( )
257
+ }
268
258
}
269
259
}
270
260
You can’t perform that action at this time.
0 commit comments