Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
934c9e6
commit 823956e
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
"@vue-flow/core": minor | ||
--- | ||
|
||
Add `useNodesData` composable | ||
|
||
## 馃 Example | ||
|
||
### Single node id | ||
|
||
```ts | ||
const nodeId = '1' | ||
|
||
const data = useNodesData(nodeId) | ||
|
||
console.log(data.value) // '[{ /* ... */ }] | ||
``` | ||
|
||
### Array of node ids | ||
```ts | ||
const nodeIds = ['1', '2', '3'] | ||
|
||
const data = useNodesData(nodeIds) | ||
|
||
console.log(data.value) // '[{ /* ... */ }] | ||
``` | ||
|
||
### Asserting data type | ||
```ts | ||
import type { Node } from '@vue-flow/core' | ||
|
||
interface Data { | ||
foo: string; | ||
bar: string; | ||
} | ||
|
||
type MyNode = Node<CustomNodeData> | ||
|
||
const nodeId = '1' | ||
|
||
const data = useNodesData([nodeId], (node): node is MyNode => { | ||
return 'foo' in node.data && 'bar' in node.data | ||
}) | ||
|
||
console.log(data.value) // '[{ /* foo: string; bar: string */ }] | ||
``` |