File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ describe('Subscriptions', () => {
202
202
expect ( spy2 ) . toHaveBeenCalledTimes ( 1 )
203
203
} )
204
204
205
- it . skip ( 'triggers pre subscriptions only once on $patch' , async ( ) => {
205
+ it ( 'triggers pre subscriptions only once on $patch' , async ( ) => {
206
206
const s1 = useStore ( )
207
207
const spy1 = jest . fn ( )
208
208
@@ -216,7 +216,7 @@ describe('Subscriptions', () => {
216
216
// adding an extra await works
217
217
// await false
218
218
// adding any other delay also works
219
- await delay ( 20 )
219
+ // await delay(20)
220
220
// await nextTick()
221
221
expect ( spy1 ) . toHaveBeenCalledTimes ( 1 )
222
222
expect ( spy1 ) . not . toHaveBeenCalledWith (
Original file line number Diff line number Diff line change @@ -252,6 +252,9 @@ function createSetupStore<
252
252
253
253
const hotState = ref ( { } as S )
254
254
255
+ // avoid triggering too many listeners
256
+ // https://github.com/vuejs/pinia/issues/1129
257
+ let activeListener : Symbol | undefined
255
258
function $patch ( stateMutation : ( state : UnwrapRef < S > ) => void ) : void
256
259
function $patch ( partialState : _DeepPartial < UnwrapRef < S > > ) : void
257
260
function $patch (
@@ -282,8 +285,11 @@ function createSetupStore<
282
285
events : debuggerEvents as DebuggerEvent [ ] ,
283
286
}
284
287
}
288
+ const myListenerId = ( activeListener = Symbol ( ) )
285
289
nextTick ( ) . then ( ( ) => {
286
- isListening = true
290
+ if ( activeListener === myListenerId ) {
291
+ isListening = true
292
+ }
287
293
} )
288
294
isSyncListening = true
289
295
// because we paused the watcher, we need to manually call the subscriptions
You can’t perform that action at this time.
0 commit comments