Skip to content

How to get updated elements on edge connect? #128

Answered by bcakmakoglu
tpoxa asked this question in Q&A
Discussion options

You must be logged in to vote

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 getNodes or getEdges (which should compute the current value without waiting for the next tick)

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.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@tpoxa
Comment options

@tpoxa
Comment options

@bcakmakoglu
Comment options

@bcakmakoglu
Comment options

Answer selected by tpoxa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants