diff --git a/packages/core/src/composables/useConnection.ts b/packages/core/src/composables/useConnection.ts new file mode 100644 index 00000000..0b3a26f3 --- /dev/null +++ b/packages/core/src/composables/useConnection.ts @@ -0,0 +1,35 @@ +import type { VueFlowStore } from '../types' +import { useVueFlow } from './useVueFlow' + +export interface UseConnectionReturn { + startHandle: VueFlowStore['connectionStartHandle'] + endHandle: VueFlowStore['connectionEndHandle'] + status: VueFlowStore['connectionStatus'] + position: VueFlowStore['connectionPosition'] +} + +/** + * Hook for accessing the ongoing connection. + * + * @returns ongoing connection: startHandle, endHandle, status, position + */ +export function useConnection(): { + startHandle: VueFlowStore['connectionStartHandle'] + endHandle: VueFlowStore['connectionEndHandle'] + status: VueFlowStore['connectionStatus'] + position: VueFlowStore['connectionPosition'] | null +} { + const { + connectionStartHandle: startHandle, + connectionEndHandle: endHandle, + connectionStatus: status, + connectionPosition: position, + } = useVueFlow() + + return { + startHandle, + endHandle, + status, + position, + } +}