if (isListening) {
debuggerEvents = event
// avoid triggering this while the store is being built and the state is being set in pinia
- } else if (isListening == false) {
+ } else if (isListening == false && !store._hotUpdating) {
// let patch send all the events together later
/* istanbul ignore else */
if (Array.isArray(debuggerEvents)) {
// add the hotUpdate before plugins to allow them to override it
if (__DEV__) {
store._hotUpdate = markRaw((newStore) => {
+ store._hotUpdating = true
newStore._hmrPayload.state.forEach((stateKey) => {
if (stateKey in store.$state) {
const newStateTarget = newStore.$state[stateKey]
}
})
+ // avoid devtools logging this as a mutation
+ isListening = false
pinia.state.value[$id] = toRef(newStore._hmrPayload, 'hotState')
+ isListening = true
for (const actionName in newStore._hmrPayload.actions) {
const action: _Method = newStore[actionName]
// update the values used in devtools and to allow deleting new properties later on
store._hmrPayload = newStore._hmrPayload
store._getters = newStore._getters
+ store._hotUpdating = false
})
const nonEnumerable = {
*/
_hotUpdate(useStore: StoreGeneric): void
+ /**
+ * Allows pausing some of the watching mechanisms while the store is being
+ * patched with a newer version.
+ *
+ * @internal
+ */
+ _hotUpdating: boolean
+
/**
* Payload of the hmr update. Dev only.
*
* @param pinia - Pinia instance to retrieve the store
* @param hot - dev only hot module replacement
*/
- (pinia?: Pinia | null | undefined, hot?: Store<Id, S, G, A>): Store<
- Id,
- S,
- G,
- A
- >
+ (pinia?: Pinia | null | undefined, hot?: StoreGeneric): Store<Id, S, G, A>
/**
* Id of the store. Used by map helpers.