feat(core): add useConnection composable
This commit is contained in:
35
packages/core/src/composables/useConnection.ts
Normal file
35
packages/core/src/composables/useConnection.ts
Normal file
@@ -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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user