expect(spy2).toHaveBeenCalledTimes(1)
})
- it.skip('triggers pre subscriptions only once on $patch', async () => {
+ it('triggers pre subscriptions only once on $patch', async () => {
const s1 = useStore()
const spy1 = jest.fn()
// adding an extra await works
// await false
// adding any other delay also works
- await delay(20)
+ // await delay(20)
// await nextTick()
expect(spy1).toHaveBeenCalledTimes(1)
expect(spy1).not.toHaveBeenCalledWith(
const hotState = ref({} as S)
+ // avoid triggering too many listeners
+ // https://github.com/vuejs/pinia/issues/1129
+ let activeListener: Symbol | undefined
function $patch(stateMutation: (state: UnwrapRef<S>) => void): void
function $patch(partialState: _DeepPartial<UnwrapRef<S>>): void
function $patch(
events: debuggerEvents as DebuggerEvent[],
}
}
+ const myListenerId = (activeListener = Symbol())
nextTick().then(() => {
- isListening = true
+ if (activeListener === myListenerId) {
+ isListening = true
+ }
})
isSyncListening = true
// because we paused the watcher, we need to manually call the subscriptions