@nanostores/vue
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -39,1 +39,9 @@ import { AnySyncTemplate, MapTemplate, Store } from 'nanostores' | ||
): void | ||
/** | ||
* Registers the store for the component inspector | ||
* | ||
* @param store Any store | ||
* @private | ||
*/ | ||
export function registerStore(store: AnyStore): void |
@@ -10,2 +10,3 @@ import { | ||
import { setupDevtoolsPlugin } from '@vue/devtools-api' | ||
import { getCurrentInstance } from 'vue' | ||
@@ -400,1 +401,10 @@ const layerId = 'nanostores' | ||
} | ||
export function registerStore(store) { | ||
let instance = getCurrentInstance() | ||
if (instance && instance.proxy) { | ||
let vm = instance.proxy | ||
let cache = '_nanostores' in vm ? vm._nanostores : (vm._nanostores = []) | ||
cache.push(store) | ||
} | ||
} |
{ | ||
"name": "@nanostores/vue", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores", | ||
@@ -23,8 +23,8 @@ "keywords": [ | ||
"engines": { | ||
"node": "^14.0.0 || ^16.0.0 || >=18.0.0" | ||
"node": "^16.0.0 || >=18.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@vue/devtools-api": ">=6.1.4", | ||
"nanostores": ">=0.7.3", | ||
"vue": ">=3.2.30" | ||
"nanostores": ">=0.8.1", | ||
"vue": ">=3.3.1" | ||
}, | ||
@@ -31,0 +31,0 @@ "peerDependenciesMeta": { |
@@ -1,9 +0,5 @@ | ||
import { | ||
getCurrentInstance, | ||
getCurrentScope, | ||
onScopeDispose, | ||
readonly, | ||
shallowRef | ||
} from 'vue' | ||
import { getCurrentScope, onScopeDispose, readonly, shallowRef } from 'vue' | ||
import { registerStore } from '../devtools/index.js' | ||
export function useStore(store) { | ||
@@ -28,8 +24,3 @@ let state = shallowRef() | ||
if (process.env.NODE_ENV !== 'production') { | ||
let instance = getCurrentInstance() | ||
if (instance && instance.proxy) { | ||
let vm = instance.proxy | ||
let cache = '_nanostores' in vm ? vm._nanostores : (vm._nanostores = []) | ||
cache.push(store) | ||
} | ||
registerStore(store) | ||
return readonly(state) | ||
@@ -36,0 +27,0 @@ } |
3
18745
14
599