File tree Expand file tree Collapse file tree 1 file changed +12
-22
lines changed Expand file tree Collapse file tree 1 file changed +12
-22
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import {
2222} from './effect'
2323import { isReactive , isShallow } from './reactive'
2424import { type Ref , isRef } from './ref'
25- import { getCurrentScope } from './effectScope'
2625
2726// These errors were transferred from `packages/runtime-core/src/errorHandling.ts`
2827// along with baseWatch to maintain code compatibility. Hence,
@@ -244,27 +243,18 @@ export function baseWatch(
244243 }
245244
246245 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+ }
268258 }
269259 }
270260
You can’t perform that action at this time.
0 commit comments