update(store): static id for store state

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-12-04 15:42:18 +01:00
parent aa72527ad2
commit 0fcf8bbeaa
3 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ export const createStore = (options?: FlowOptions) => {
}
}
const store = useNewStore(storageKey, preloadedState)
if (withStorage && storageKey === store.id?.value) {
if (withStorage && storageKey === store.id) {
const toObject = onLoadToObject(store.state)
watch(
store.state,
@@ -39,7 +39,7 @@ export const createStore = (options?: FlowOptions) => {
export default (options?: FlowOptions): FlowStore => {
const currentInstance = getCurrentInstance()
let store = currentInstance ? inject(StoreSymbol, undefined) : false
if (!store || (store && options?.id && options.id !== store.id?.value)) {
if (!store || (store && options?.id && options.id !== store.id)) {
store = createStore(options)
}
if (currentInstance) provide(StoreSymbol, store)