update: add hmr to statestore
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { setActivePinia, createPinia, defineStore, StoreDefinition } from 'pinia'
|
import { setActivePinia, createPinia, defineStore, StoreDefinition, acceptHMRUpdate } from 'pinia'
|
||||||
import microDiff from 'microdiff'
|
import microDiff from 'microdiff'
|
||||||
import { FlowState, Node, FlowActions, Elements, FlowGetters, Edge, GraphNode, NextElements } from '~/types'
|
import { FlowState, Node, FlowActions, Elements, FlowGetters, Edge, GraphNode, NextElements } from '~/types'
|
||||||
import {
|
import {
|
||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
getConnectedEdges,
|
getConnectedEdges,
|
||||||
getNodesInside,
|
getNodesInside,
|
||||||
getRectOfNodes,
|
getRectOfNodes,
|
||||||
isNode,
|
|
||||||
parseElements,
|
parseElements,
|
||||||
defaultNodeTypes,
|
defaultNodeTypes,
|
||||||
defaultEdgeTypes,
|
defaultEdgeTypes,
|
||||||
@@ -19,13 +18,10 @@ import parseElementsWorker from '~/workers/parseElements'
|
|||||||
|
|
||||||
const pinia = createPinia()
|
const pinia = createPinia()
|
||||||
|
|
||||||
export default function flowStore(
|
export default (id: string, preloadedState: FlowState) => {
|
||||||
id: string,
|
|
||||||
preloadedState: FlowState,
|
|
||||||
): StoreDefinition<string, FlowState, FlowGetters, FlowActions> {
|
|
||||||
setActivePinia(pinia)
|
setActivePinia(pinia)
|
||||||
|
|
||||||
return defineStore({
|
const store: StoreDefinition<string, FlowState, FlowGetters, FlowActions> = defineStore({
|
||||||
id: id ?? 'vue-flow',
|
id: id ?? 'vue-flow',
|
||||||
state: () => ({
|
state: () => ({
|
||||||
...preloadedState,
|
...preloadedState,
|
||||||
@@ -281,4 +277,10 @@ export default function flowStore(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (import.meta.hot) {
|
||||||
|
import.meta.hot.accept(acceptHMRUpdate(store, import.meta.hot))
|
||||||
|
}
|
||||||
|
|
||||||
|
return store
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user