Skip to content

Commit

Permalink
fix(devtools): time travel and state display
Browse files Browse the repository at this point in the history
Fix #394

Fix #19
  • Loading branch information
posva committed Mar 23, 2021
1 parent d6b8968 commit 043ae2a
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/devtools.ts
@@ -1,6 +1,4 @@
import { Pinia } from './rootStore'
import { DevtoolHook, StateTree, StoreWithState } from './types'
import { assign } from './utils'

const target =
typeof window !== 'undefined'
Expand Down Expand Up @@ -65,7 +63,10 @@ export function useStoreDevtools(
// tell the devtools we added a module
rootStore.registerModule(store.$id, store)

Object.defineProperty(rootStore.state, store.$id, stateDescriptor)
Object.defineProperty(rootStore.state, store.$id, {
enumerable: true,
...stateDescriptor,
})

// Vue.set(rootStore.state, store.name, store.state)
// the trailing slash is removed by the devtools
Expand All @@ -77,9 +78,14 @@ export function useStoreDevtools(

store.$subscribe((mutation, state) => {
rootStore.state[store.$id] = state
devtoolHook.emit('vuex:mutation', {
type: `[${mutation.storeName}] ${mutation.type}`,
payload: mutation.payload,
})
devtoolHook.emit(
'vuex:mutation',
{
type: `[${mutation.storeName}] ${mutation.type}`,
payload: mutation.payload,
},
// this doesn't seem to be used by the devtools but it's in vuex codebase
rootStore.state
)
})
}

0 comments on commit 043ae2a

Please sign in to comment.