How to get updated elements on edge connect? #128
-
Hey. Vue-flow is awesome! I am building a flow-based programming platform with it. The goal is to emit updated elements (edge included) when the edge is added. Can someone help me figure this out? onConnect(params => {
addEdges([params]); // result is void, can not emit updated elements from here
// <--- too early, vue-flow did not update v-model yet
}
) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Good point, I could add the current edges / nodes when adding a new element as the return value so something like this would work: const currentEdges = addEdges([params]) But for now you could probably just wait for the "next tick" to check the elements in either your v-model or a getter like so either this onConnect((params )=> {
addEdges([params]);
nextTick(() => {
// v-model should be updated now
})
}
) or const { getEdges, addEdges, onConnect } = useVueFlow()
onConnect((params )=> {
addEdges([params]);
const currentEdges = getEdges.value
}
) should work. |
Beta Was this translation helpful? Give feedback.
Good point, I could add the current edges / nodes when adding a new element as the return value so something like this would work:
But for now you could probably just wait for the "next tick" to check the elements in either your v-model or a getter like
getNodes
orgetEdges
(which should compute the current value without waiting for the next tick)so either this
or
should work.