subscriptions are lost during HMR
Author: duoyueCreated Jan 25, 2022Updated Nov 8, 2022
Labels✨ enhancementHMR 🔥
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);
});
}
Source: vuejs/pinia