refactor(store)!: replace store injection with VueFlow injection

This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent c80ab8fe50
commit 17a1b08ee0
9 changed files with 152 additions and 152 deletions
+5 -3
View File
@@ -1,7 +1,8 @@
<script lang="ts" setup>
import { createHooks, initFlow } from '../../store'
import { createHooks, useHooks } from '../../store'
import type { FlowProps } from '../../types/flow'
import ZoomPane from '../ZoomPane/ZoomPane.vue'
import { useVueFlow } from '../../composables'
const props = withDefaults(defineProps<FlowProps>(), {
snapToGrid: false,
@@ -19,8 +20,9 @@ const props = withDefaults(defineProps<FlowProps>(), {
paneMoveable: true,
})
const emit = defineEmits([...Object.keys(createHooks())])
const store = initFlow(emit, props.id)
nextTick(() => store.setState(props))
const { store } = useVueFlow(props)
useHooks(store, emit)
watch(
() => props,
(v) => nextTick(() => store.setState(v)),