]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(devtools): register stores
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 3 Jun 2021 14:02:01 +0000 (16:02 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 3 Jun 2021 14:02:01 +0000 (16:02 +0200)
docs/.vitepress/components/TestStore.vue
src/devtools/plugin.ts

index 2a624eea4e503cfa5bb7a2aa83b29300a767d874..156f07f4deed5d2dacbf502c3e97e1f86cc4b4a2 100644 (file)
@@ -3,12 +3,20 @@
     I have a store "{{ userStore.name }}". I have
     {{ cartStore.items.length }} items in the cart.
   </p>
+  <div>
+    <p>Counter: {{ counterStore.double }} = 2 x {{ counterStore.n }}</p>
+    <button @click="counterStore.increment(10)">Increment</button>
+    <button @click="counterStore.fail">Fail</button>
+    <button @click="counterStore.decrementToZero(300)">Countdown!</button>
+  </div>
 </template>
 
 <script setup lang="ts">
 import { useUserStore } from '../stores/user'
 import { useCartStore } from '../stores/cart'
+import { useCounter } from '../stores/counter'
 
 const userStore = useUserStore()
 const cartStore = useCartStore()
+const counterStore = useCounter()
 </script>
index 9e90aae7caf9f1e89e8251aaf47ef3eb848aa64b..af98d1a615ae0af36783d29f688bed09982f2c8d 100644 (file)
@@ -42,11 +42,13 @@ function addDevtools(app: App, store: Store) {
   // TODO: we probably need to ensure the latest version of the store is kept:
   // without effectScope, multiple stores will be created and will have a
   // limited lifespan for getters.
+  // add a dev only variable that is removed in unmounted and replace the store
   let hasSubscribed = true
   if (!registeredStores.has(store.$id)) {
     registeredStores.set(store.$id, store)
     componentStateTypes.push('🍍 ' + store.$id)
-    hasSubscribed = true
+    hasSubscribed = false
+    console.log('registing for the first time')
   }
 
   setupDevtoolsPlugin(