From 1012f2cae923c20c5f06605685eef6b7477dd539 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:18:06 +0100 Subject: [PATCH] feat(core): add `useConnection` composable --- .../core/src/composables/useConnection.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/core/src/composables/useConnection.ts 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, + } +}