feat(store, flow)!: Add useNode/useEdge-state helpers

* for two way binding use the helpers
This commit is contained in:
Braks
2021-12-20 19:29:52 +01:00
parent 81c8145f3a
commit c80ab8fe50
5 changed files with 21 additions and 11 deletions
+8
View File
@@ -106,6 +106,14 @@ export default (options?: FlowOptions): UseVueFlow => {
const store = useStore(options)
return {
store,
useNodesState: (nodes) => {
store.setNodes(nodes)
return store.nodes
},
useEdgesState: (edges) => {
store.setEdges(edges)
return store.edges
},
applyNodeChanges: (changes) => applyNodeChanges(changes, store.nodes),
applyEdgeChanges: (changes) => applyEdgeChanges(changes, store.edges),
...store.hooksOn,