From 5169edad6d664f26ccd66b096e0475ebdf2c20b2 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Sun, 5 Nov 2023 18:19:59 +0100 Subject: [PATCH] docs(guide): add section on updating edge data --- docs/src/guide/edge.md | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/docs/src/guide/edge.md b/docs/src/guide/edge.md index 22cb5a90..45dad5d9 100644 --- a/docs/src/guide/edge.md +++ b/docs/src/guide/edge.md @@ -678,3 +678,84 @@ const elements = ref([ ::: tip To override the styles of the default theme, visit the [Theming section](/guide/theming). ::: + +## Updating Edge Data + +Since edges are reactive object, you can update their data at any point by simply mutating it. +This allows you to change the label, or even add new properties to the data object at any point in time. + +There are multiple ways of achieving this, here are some examples: + +::: code-group + +```vue [useEdge] + + +``` + +```ts [useVueFlow] +import { useVueFlow } from '@vue-flow/core' + +const instance = useVueFlow() + +// find the node in the state by its id +const edge = instance.findEdge(edgeId) + +edge.data = { + ...edge.data, + hello: 'world', +} +``` + +```vue [v-model] + + + +``` + +:::