Skip to content

Commit 1dff3a1

Browse files
committed
chore(changeset): add
1 parent cecf9d4 commit 1dff3a1

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.changeset/old-jokes-raise.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
"@vue-flow/core": minor
3+
---
4+
5+
Add `useNodesData` composable
6+
7+
## 🧙 Example
8+
9+
### Single node id
10+
11+
```ts
12+
const nodeId = '1'
13+
14+
const data = useNodesData(nodeId)
15+
16+
console.log(data.value) // '[{ /* ... */ }]
17+
```
18+
19+
### Array of node ids
20+
```ts
21+
const nodeIds = ['1', '2', '3']
22+
23+
const data = useNodesData(nodeIds)
24+
25+
console.log(data.value) // '[{ /* ... */ }]
26+
```
27+
28+
### Asserting data type
29+
```ts
30+
import type { Node } from '@vue-flow/core'
31+
32+
interface Data {
33+
foo: string;
34+
bar: string;
35+
}
36+
37+
type MyNode = Node<CustomNodeData>
38+
39+
const nodeId = '1'
40+
41+
const data = useNodesData([nodeId], (node): node is MyNode => {
42+
return 'foo' in node.data && 'bar' in node.data
43+
})
44+
45+
console.log(data.value) // '[{ /* foo: string; bar: string */ }]
46+
```

0 commit comments

Comments
 (0)