type: getStoreType(store.$id),
key: 'state',
editable: true,
- value: store.$state,
+ value: store._isOptionsAPI
+ ? {
+ _custom: {
+ value: store.$state,
+ actions: [
+ {
+ icon: 'restore',
+ tooltip: 'Reset the state of this store',
+ action: () => store.$reset(),
+ },
+ ],
+ },
+ }
+ : store.$state,
})
if (store._getters && store._getters.length) {
let activeAction: number | undefined
/**
- * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the context of all actions, allowing us to set `runningAction` on each access and effectively associating any state mutation to the action.
+ * Patches a store to enable action grouping in devtools by wrapping the store with a Proxy that is passed as the
+ * context of all actions, allowing us to set `runningAction` on each access and effectively associating any state
+ * mutation to the action.
*
* @param store - store to patch
* @param actionNames - list of actionst to patch
return
}
+ // detect option api vs setup api
+ if (options.state) {
+ store._isOptionsAPI = true
+ }
+
// only wrap actions in option-defined stores as this technique relies on
// wrapping the context of the action with a proxy
if (typeof options.state === 'function') {
*/
_getters?: string[]
+ /**
+ * Used (and added) by devtools plugin to detect Setup vs Options API usage.
+ *
+ * @internal
+ */
+ _isOptionsAPI?: boolean
+
/**
* Used by devtools plugin to retrieve properties added with plugins. Removed
* in production. Can be used by the user to add property keys of the store