Skip to content

subscriptions are lost during HMR #991

@duoyue

Description

@duoyue

I have some code like this , it could output correctly when app first loaded or refresh ,but don‘t work after HMR.

const pinia = createPinia();
pinia.use(({ store }) => {
  store.$subscribe((mutations, state) => {
    console.log('trigger subscritions ', mutations, state);
  });
});

I have add some breakpoints in Pinia.js ,and found that subscriptions is emty [] after HMR.

// the  "subscriptions" is empty [] after HMR
function triggerSubscriptions(subscriptions, ...args) {
    subscriptions.forEach((callback) => {
        callback(...args);
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    HMR 🔥Related to Hot Module Replacement✨ enhancementNew feature or request

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions