]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
refactor(devtools): reuse var
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 14 Jun 2021 12:49:47 +0000 (14:49 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Mon, 14 Jun 2021 12:49:47 +0000 (14:49 +0200)
src/devtools/plugin.ts

index d5c255fe2a18f8f955fce4a6f9c0739a9ccf66a8..09171ae82ede8b8ca5325130e0f220bcd92d7c17 100644 (file)
@@ -44,9 +44,10 @@ function addDevtools(app: App, store: Store) {
   // limited lifespan for getters.
   // add a dev only variable that is removed in unmounted and replace the store
   let hasSubscribed = true
+  const storeType = '🍍 ' + store.$id
   if (!registeredStores.has(store.$id)) {
     registeredStores.set(store.$id, store)
-    componentStateTypes.push('🍍 ' + store.$id)
+    componentStateTypes.push(storeType)
     hasSubscribed = false
   }
 
@@ -121,7 +122,7 @@ function addDevtools(app: App, store: Store) {
 
             Object.values(piniaStores).forEach((store) => {
               payload.instanceData.state.push({
-                type: '🍍 ' + store.$id,
+                type: storeType,
                 key: 'state',
                 editable: true,
                 value: store.$state,
@@ -129,7 +130,7 @@ function addDevtools(app: App, store: Store) {
 
               if (store._getters && store._getters.length) {
                 payload.instanceData.state.push({
-                  type: '🍍 ' + store.$id,
+                  type: storeType,
                   key: 'getters',
                   editable: false,
                   value: store._getters.reduce((getters, key) => {