Skip to content

Commit 533e37e

Browse files
committed
chore(core,composables): cleanup useNodesData types
1 parent 7f6ae2f commit 533e37e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/core/src/composables/useNodesData.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import type { ComputedRef } from 'vue'
12
import { computed } from 'vue'
23
import type { GraphNode, Node } from '../types'
34
import { useVueFlow } from './useVueFlow'
45

6+
type NodeData<NodeType extends Node = GraphNode> = NonNullable<NodeType['data']>
7+
58
/**
69
* Composable for receiving data of one or multiple nodes
710
*
@@ -10,12 +13,12 @@ import { useVueFlow } from './useVueFlow'
1013
* @param guard - Optional guard function to narrow down the node type
1114
* @returns An array of data objects
1215
*/
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>[]>
1518
export function useNodesData<NodeType extends Node = GraphNode>(
1619
nodeIds: string[],
1720
guard: (node: Node) => node is NodeType,
18-
): NodeType['data'][]
21+
): ComputedRef<NodeData<NodeType>[]>
1922
export function useNodesData(nodeIds: any): any {
2023
const { findNode } = useVueFlow()
2124

0 commit comments

Comments
 (0)