File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
packages/core/src/composables Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change
1
+ import type { ComputedRef } from 'vue'
1
2
import { computed } from 'vue'
2
3
import type { GraphNode , Node } from '../types'
3
4
import { useVueFlow } from './useVueFlow'
4
5
6
+ type NodeData < NodeType extends Node = GraphNode > = NonNullable < NodeType [ 'data' ] >
7
+
5
8
/**
6
9
* Composable for receiving data of one or multiple nodes
7
10
*
@@ -10,12 +13,12 @@ import { useVueFlow } from './useVueFlow'
10
13
* @param guard - Optional guard function to narrow down the node type
11
14
* @returns An array of data objects
12
15
*/
13
- export function useNodesData < NodeType extends Node = GraphNode > ( nodeId : string ) : NodeType [ 'data' ] | null
14
- export function useNodesData < NodeType extends Node = GraphNode > ( nodeIds : string [ ] ) : NodeType [ 'data' ] [ ]
16
+ export function useNodesData < NodeType extends Node = GraphNode > ( nodeId : string ) : ComputedRef < NodeData < NodeType > | null >
17
+ export function useNodesData < NodeType extends Node = GraphNode > ( nodeIds : string [ ] ) : ComputedRef < NodeData < NodeType > [ ] >
15
18
export function useNodesData < NodeType extends Node = GraphNode > (
16
19
nodeIds : string [ ] ,
17
20
guard : ( node : Node ) => node is NodeType ,
18
- ) : NodeType [ 'data' ] [ ]
21
+ ) : ComputedRef < NodeData < NodeType > [ ] >
19
22
export function useNodesData ( nodeIds : any ) : any {
20
23
const { findNode } = useVueFlow ( )
21
24
You can’t perform that action at this time.
0 commit comments