File tree Expand file tree Collapse file tree 6 files changed +17
-48
lines changed Expand file tree Collapse file tree 6 files changed +17
-48
lines changed Original file line number Diff line number Diff line change @@ -1089,11 +1089,11 @@ describe('reactivity/effect', () => {
1089
1089
expect ( obj . foo ) . toBe ( 2 )
1090
1090
1091
1091
runner . effect . resume ( )
1092
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 1 )
1092
+ expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
1093
1093
expect ( obj . foo ) . toBe ( 2 )
1094
1094
1095
1095
obj . foo ++
1096
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
1096
+ expect ( fnSpy ) . toHaveBeenCalledTimes ( 3 )
1097
1097
expect ( obj . foo ) . toBe ( 3 )
1098
1098
} )
1099
1099
@@ -1110,12 +1110,12 @@ describe('reactivity/effect', () => {
1110
1110
expect ( fnSpy ) . toHaveBeenCalledTimes ( 1 )
1111
1111
expect ( obj . foo ) . toBe ( 2 )
1112
1112
1113
- runner . effect . resume ( true )
1114
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
1115
- expect ( obj . foo ) . toBe ( 2 )
1116
-
1117
1113
obj . foo ++
1118
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 3 )
1114
+ expect ( fnSpy ) . toHaveBeenCalledTimes ( 1 )
1115
+ expect ( obj . foo ) . toBe ( 3 )
1116
+
1117
+ runner . effect . resume ( )
1118
+ expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
1119
1119
expect ( obj . foo ) . toBe ( 3 )
1120
1120
} )
1121
1121
} )
Original file line number Diff line number Diff line change @@ -316,39 +316,11 @@ describe('reactivity/effect/scope', () => {
316
316
await nextTick ( )
317
317
expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
318
318
319
- scope . resume ( )
320
- await nextTick ( )
321
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
322
-
323
- counter . num ++
324
- await nextTick ( )
325
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 3 )
326
- } )
327
-
328
- it ( 'should execute all saved run methods in effects immediately upon resuming' , async ( ) => {
329
- const counter = reactive ( { num : 0 } )
330
- const fnSpy = vi . fn ( ( ) => counter . num )
331
- const scope = new EffectScope ( )
332
- scope . run ( ( ) => {
333
- effect ( fnSpy )
334
- } )
335
-
336
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 1 )
337
-
338
319
counter . num ++
339
320
await nextTick ( )
340
321
expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
341
322
342
- scope . pause ( )
343
- counter . num ++
344
- await nextTick ( )
345
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 2 )
346
-
347
- scope . resume ( true )
323
+ scope . resume ( )
348
324
expect ( fnSpy ) . toHaveBeenCalledTimes ( 3 )
349
-
350
- counter . num ++
351
- await nextTick ( )
352
- expect ( fnSpy ) . toHaveBeenCalledTimes ( 4 )
353
325
} )
354
326
} )
Original file line number Diff line number Diff line change @@ -103,18 +103,15 @@ export class ReactiveEffect<T = any> {
103
103
104
104
/**
105
105
* Resumes the execution of the reactive effect.
106
- * @param {boolean } immediate - If true, executes the saved run method immediately upon resuming.
107
106
*/
108
- resume ( immediate : boolean = false ) {
107
+ resume ( ) {
109
108
if ( ! this . _isStopped ) {
110
109
this . active = true
111
110
if ( pausedQueueEffects . has ( this ) ) {
112
111
pausedQueueEffects . delete ( this )
113
112
queueEffectSchedulers . push ( this . scheduler ! )
114
- if ( immediate ) {
115
- pauseScheduling ( )
116
- resetScheduling ( )
117
- }
113
+ pauseScheduling ( )
114
+ resetScheduling ( )
118
115
}
119
116
}
120
117
}
Original file line number Diff line number Diff line change @@ -75,11 +75,11 @@ export class EffectScope {
75
75
this . _isPaused = false
76
76
if ( this . scopes ) {
77
77
for ( let i = 0 , l = this . scopes . length ; i < l ; i ++ ) {
78
- this . scopes [ i ] . resume ( immediate )
78
+ this . scopes [ i ] . resume ( )
79
79
}
80
80
}
81
81
for ( let i = 0 , l = this . effects . length ; i < l ; i ++ ) {
82
- this . effects [ i ] . resume ( immediate )
82
+ this . effects [ i ] . resume ( )
83
83
}
84
84
}
85
85
}
Original file line number Diff line number Diff line change @@ -1312,7 +1312,7 @@ describe('api: watch', () => {
1312
1312
expect ( cb ) . toHaveBeenCalledTimes ( 3 )
1313
1313
expect ( cb ) . toHaveBeenLastCalledWith ( 4 , 3 , expect . any ( Function ) )
1314
1314
1315
- resume ( true )
1315
+ resume ( )
1316
1316
await nextTick ( )
1317
1317
expect ( cb ) . toHaveBeenCalledTimes ( 4 )
1318
1318
expect ( cb ) . toHaveBeenLastCalledWith ( 5 , 4 , expect . any ( Function ) )
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ export type WatchStopHandle = () => void
82
82
83
83
export interface WatchHandle extends WatchStopHandle {
84
84
pause : ( ) => void
85
- resume : ( immediate ?: boolean ) => void
85
+ resume : ( ) => void
86
86
stop : ( ) => void
87
87
}
88
88
@@ -393,8 +393,8 @@ function doWatch(
393
393
}
394
394
395
395
const watchHandle : WatchHandle = ( ) => unwatch ( )
396
- watchHandle . pause = ( ) => effect . pause ( )
397
- watchHandle . resume = immediate => effect . resume ( immediate )
396
+ watchHandle . pause = effect . pause . bind ( effect )
397
+ watchHandle . resume = effect . resume . bind ( effect )
398
398
watchHandle . stop = unwatch
399
399
400
400
if ( __DEV__ ) {
You can’t perform that action at this time.
0 commit comments